ashx或者aspx jsonp处理
服务端:
if (context.Request.Cookies["CheckCode5"] == null) { context.Response.Write("success_jsonpCallback(-1)"); context.Response.End(); } result = CheckPhoneCodeLogin(context); result = "success_jsonpCallback(" + result + ")"; context.Response.Write(result);
前端:
$.ajax({ url:'//CheckUserLoginCode.ashx', data:'action=checkphoneCodeLoginWWW&codeVal=4245', async:false, dataType : "jsonp", jsonp: "callback", jsonpCallback: "success_jsonpCallback", success: function(data) { if (data == 1) { } else if (data == "-1") { } else { } } });
服务端返回需用相应字符串包裹