---
title: "jquery异步校验"
author: "kasuqi"
date: "2010-10-26T14:44:52Z"
tags: []
categories: ["Web前端"]
slug: "jquery"
draft: false
lastmod: "2010-10-26T15:06:29Z"
id: 794409
url: "https://kasuqi.iteye.com/blog/794409"
---

```
        var phone = getphone();
        $.post("${ctx}/dataManage/qryisExitPhone.action", {
            "phone" : phone
            ,"hiphone" : hiphone
        }, function(date) {
            if (date == 'true') {
                //alert("电话号码已经存在，请重新输入");
                $("#telerror").text("电话号码已经存在，请重新输入").css("color","red").show();
            }else
            {
                //此处用的是猫冬的校验框架
                if(jQuery.formValidator.pageIsValid('1')){
                    document.costumeForm.action = "updSmData.action?retablerID=" + id+"&memID="+mID;
                    document.costumeForm.submit();
                }
            }
        });
```

 

简要说明

.post语法格式  :jQuery.post(url, *\[data]* , *\[callback]* , *\[type]* )

  1.调用一个时间执行此处的代码

  2.url:   "${ctx}/dataManage/qryisExitPhone.action"

  3.\[date]:   "phone" : phone ,"hiphone" : hiphone

  4.\[callback] function(date)  date为action层打印给页面的字符串

  getPrintWriter().print(flag);  //flag为true或false

  再判断date,再做相应的处理