我自己本机上面用服务器地址测试成功,在别人电脑上用服务器地址测试都是弹出错误。
前台代码$(document).ready(function(){
$.formValidator.initConfig({formid:"form1",onerror:function(msg){alert(msg)},onsuccess:function(){
return true;}});
$("#username").formValidator({onshow:"请输入用户名",onfocus:"用户名至少3个字符,最多30个字符",oncorrect:"该用户名可以注册"}).inputValidator({min:5,max:30,onerror:"你输入的用户名非法,请确认"}).regexValidator({regexp:"username",datatype:"enum",onerror:"用户名格式不正确"})
.ajaxValidator({
type : "get",
url : "http://w406750.s182.ufhosted.com/stylist_module/register.php",
datatype : "json",
success : function(data){
if( data == 1 )
{
return true;
}
else
{
return false;
}
},
buttons: $("#button"),
error: function(){alert("服务器没有返回数据,可能服务器忙,请重试");},
onerror : "该用户名不可用,请更换用户名",
onwait : "正在对用户名进行合法性校验,请稍候..."
});
后台代码/*
* 用户进行验证
*/
$usernames = trim($_GET['username']); //获得用户名
$result = 1;
$result1 = 2;
if ($usernames) {
if ($user->checkUserName($usernames)) { //查询数据库用户名是否存在
echo $result;
} else {
echo $result1;
}
return;
}
大家给个建议什么的啊,急,本人不甚感激!!!!
前台代码$(document).ready(function(){
$.formValidator.initConfig({formid:"form1",onerror:function(msg){alert(msg)},onsuccess:function(){
return true;}});
$("#username").formValidator({onshow:"请输入用户名",onfocus:"用户名至少3个字符,最多30个字符",oncorrect:"该用户名可以注册"}).inputValidator({min:5,max:30,onerror:"你输入的用户名非法,请确认"}).regexValidator({regexp:"username",datatype:"enum",onerror:"用户名格式不正确"})
.ajaxValidator({
type : "get",
url : "http://w406750.s182.ufhosted.com/stylist_module/register.php",
datatype : "json",
success : function(data){
if( data == 1 )
{
return true;
}
else
{
return false;
}
},
buttons: $("#button"),
error: function(){alert("服务器没有返回数据,可能服务器忙,请重试");},
onerror : "该用户名不可用,请更换用户名",
onwait : "正在对用户名进行合法性校验,请稍候..."
});
后台代码/*
* 用户进行验证
*/
$usernames = trim($_GET['username']); //获得用户名
$result = 1;
$result1 = 2;
if ($usernames) {
if ($user->checkUserName($usernames)) { //查询数据库用户名是否存在
echo $result;
} else {
echo $result1;
}
return;
}
大家给个建议什么的啊,急,本人不甚感激!!!!
http://w406750.s182.ufhosted.com/stylist_module/register.php?username=用户名
返回什么结果?
2、http://w406750.s182.ufhosted.com/stylist_module/register.php?username=xxxxx
返回:({modify:null})
不是预期的1或2
type : "GET",
url : "http://w406750.s182.ufhosted.com/stylist_module/register.php?callback=?",
datatype : "jsonp",
jsonp: 'callback',
success : function(callback){
alert("Data load:"+callback.modify);
$("#result").html(callback.modify);
if(callback.modify == null )
{
return true;
}
else
{
return false;
}
},
buttons: $("#button"),
error: function(){alert("服务器没有返回数据,可能服务器忙,请重试");},
onerror : "该用户名不可用,请更换用户名",
onwait : "正在对用户名进行合法性校验,请稍候..."
});
后台
$usernames = trim($_GET['username']); //获得用户名
//$result = 1;
//$result1 = 2;
if ($usernames) {
if ($user->checkUserName($usernames)) { //查询数据库用户名是否存在
$result=$uesrnames;
} else {
$result=$usernames;
}
$k = $_GET['callback'];
echo $k."({modify:".json_encode($result)."})";exit;
//return;
}
我现在按他们说的用跨域传递来做,存在用户名显示出来,没有的话就显示null,但还是在别人机子上面错误,而我本机可以高手指点下。。