<span> 手机号:</span><input type="text" placeholder="请输入正确的手机号" name="mobile_phone" id="mobile_phone" onBlur="check_username(this.value)"/>
- function check_username(mobile_phone)
- {
- $.ajax({
- url: "xxxx.php?", // 请求的 url 地址
- dataType: "json", // 返回格式为 json
- async: true, // 请求是否异步, 默认为异步, 这也是 ajax 重要特性
- data: {
- "act": "check_name",
- "mobile": mobile_phone
- }, // 参数值
- type: "POST", // 请求方式
- success: function(req) {
- // 请求成功时处理
- //console.log(req);
- if(req.status==1)// 成功
- {
- }else
- {
- }
- },
- error: function() {
- // 请求出错处理
- }
- });
- }
来源: http://www.bubuko.com/infodetail-2596508.html