jQueryformValidator 如何将返回信息填入 onerror中 

梦宇飞 2009-10-24 01:28:24
function no_selected(){
var parentid=$('#parentid');
var parentid_selectValue=parentid.val();
var currSelectIndex=$('#current_parentid').val();
var url="__URL__/no_selected";
var pars='/current_id/'+ currSelectIndex +'/source_id/'+ parentid_selectValue +'/temp/'+Math.random()+'/';
$(document).ready(function(){
$.formValidator.initConfig({formid:"Form1",onerror:function(msg){alert(msg)},onsuccess:function(){return false;}});
$("#current_parentid").formValidator({tipid:"result",onshow:"请选择目标分类!",onfocus:"目标分类不能为空!",oncorrect:"谢谢你的合作"})
.inputValidator({min:1,onerror:"目标分类不能为空!"})
.ajaxValidator({
type : "POST",
url : "__URL__/no_selected"+pars,
datatype : "html",
success : function(data){
if( data == "1" )
{
return true;
}
else
{
alert(data);
$("#result").html(data);
return false;
}
},
buttons: $("#Submit"),
error: function(){alert("服务器没有返回数据,可能服务器忙,请重试");},
onerror :'验证失败!',
onwait : "正在对用户名进行合法性校验,请稍候..."
})
});
}





function no_selected(){//非正常选取
$cata= D($this->cata_table);
$current_id=$_GET["current_id"];
$source_id=$_GET["source_id"];
if (!$source_id){
// $this->ajaxReturn('','源分类不能为空!',0);
echo '源分类不能为空!';exit;
}

if (!$current_id){
//$this->ajaxReturn('','目标分类不能为空!',0);
echo '目标分类不能为空!';exit;

}

if ($current_id==$source_id){
$err="<font color=\"red\">对不起,源分类不能与目标分类相同!</font>";
// $this->ajaxReturn('',$err,0);
echo $err;exit;
}

$osql="select roue_id,parentid from ". $this->table_name . " where news_catas_id=$source_id";
$rs=$cata->query($osql);
$parentlist=$rs[0]["roue_id"];

$not_sql="select news_catas_id from ". $this->table_name. " ";
$where="where roue_id like '$parentlist,%' or roue_id='$parentlist'";
$not_sql= $not_sql.$where;
$result=$cata->query($not_sql);
// $num= $cata->where($where)->count('news_catas_id');//本次循环的纪录总数
foreach($result as $nrs){
$not_id=$nrs["news_catas_id"];
if($not_id==$current_id){//如果当前分类ID 等于不允许分类ID
$msg="<font color=\"red\">对不起,不能选择自身及自身以下分类!</font>";
//$this->ajaxReturn('',$msg,0);
echo $msg;exit;

}

}
//$this->ajaxReturn('','恭喜类别选择正确!',1); //如果当前分类是根分类则直接退出
echo 1;
}

...全文
73 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
梦宇飞 2009-10-26
  • 打赏
  • 举报
回复
up
梦宇飞 2009-10-24
  • 打赏
  • 举报
回复
为什么程序重复的执行,死循环了
梦宇飞 2009-10-24
  • 打赏
  • 举报
回复
如何将 $data  填到  onerror :'....验证失败!', 这中

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧