同步请求,async(是否异步)
//同步请求,等待并接收返回的结果
var result = $.ajax({ type: "GET", url: address, async: false }).responseText;

//同步验证 验证码是否正确 
var msg = $.ajax({ type: "POST", url: "/IsVerifyCode.html?", data: "verifyCode=1978", async: false }).responseText;
if (msg == "false") {
   $.jBox.tip("验证码有误");
   $("input[name='_member.VerifyCode']").focus();
   return false;
}
var regMobile = /^(13|14|15|18)\d{9}$/;
if (!regMobile.test(msg)) {
   $.jBox.tip("请输入您的手机请输入有效的手机号码号码");
   return false;
}

数据地址:http://cy.com/Json_cross_domain/Handler1.ashx 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;

/// <summary>
/// Handler1 的摘要说明
/// </summary>
public class Handler1 : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string jsoncall = context.Request["jsoncallback"];
        Users u = new Users();
        u.Name = "招运堂";
        u.Phone = "13457803838";
        u.Email = "zhaoyuntang@126.com";
        //JavaScriptConvert.SerializeObject(s_result);
        string json = JsonConvert.SerializeObject(u);
        context.Response.Write(jsoncall + "(" + json + ")");
    }
    public class Users
    {
        public string Name { get; set; }
        public string Phone { get; set; }
        public string Email { get; set; }
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}
View Code

相关文章: