jionelmessi
دوشنبه 19 تیر 1391, 13:48 عصر
سلام
من یک سری کد ای جکس دارم با این که هیچ خطایی نداره اجرا نمیشخ و اطلاعات را سند نمیکنه من از شی xmlhttp استفاده می کنم
این کدای ای جکسیمه
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
}
function checkUser()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return;
url='check?user='+document.getElementById('user'). value;
//alert(url);
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
if (xmlHttp.responseText==1)
{
document.getElementById("user").style.border="1px solid #FF0000";
}
else{
document.getElementById("user").style.border="1px solid #00CC00";
}
}
}
این اچ تی ام المه
<html>
<head>
<title></title>
</head>
<body>
<input type="text" id="user">
<input type="button" onclick="checkUser()">
</body>
</html>
اینم کد php
<?php
$user=$_GET['user'];
if($user=="user")
echo 1;
else
echo 0;
?>
میخوام اگه طرف تو فیلد ما کلمه user را وارد کرد بهم با سبز شدن کادر اطلاع بده به صورت ای جکس فبلا این کدم اجرا میشد حالا نمیشه ممنون میشم راهنماییم کنین
من یک سری کد ای جکس دارم با این که هیچ خطایی نداره اجرا نمیشخ و اطلاعات را سند نمیکنه من از شی xmlhttp استفاده می کنم
این کدای ای جکسیمه
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
}
function checkUser()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return;
url='check?user='+document.getElementById('user'). value;
//alert(url);
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
if (xmlHttp.responseText==1)
{
document.getElementById("user").style.border="1px solid #FF0000";
}
else{
document.getElementById("user").style.border="1px solid #00CC00";
}
}
}
این اچ تی ام المه
<html>
<head>
<title></title>
</head>
<body>
<input type="text" id="user">
<input type="button" onclick="checkUser()">
</body>
</html>
اینم کد php
<?php
$user=$_GET['user'];
if($user=="user")
echo 1;
else
echo 0;
?>
میخوام اگه طرف تو فیلد ما کلمه user را وارد کرد بهم با سبز شدن کادر اطلاع بده به صورت ای جکس فبلا این کدم اجرا میشد حالا نمیشه ممنون میشم راهنماییم کنین