Jquery跨域调用后台方法
2014-09-18 16:05 Yang-Onion 阅读(265) 评论(0) 编辑 收藏 举报//前端JS function CallHandlerByJquery() { var url = "http://" + window.location.hostname + "/Helper.ashx?FLAG=2&BIZINST_GUID=276259&callback=?&rand="+Math.random(); $.ajaxSettings.async = false; $.getJSON(url, function (data) { alert(data.state + "|" + data.msg); }); } //后台方法 public void ProcessRequest(HttpContext context) { string jsonResult = string.Empty; string callback = context.Request.QueryString["callback"]; //业务逻辑 jsonResult = "{state:'0',msg:'操作失败'}"; } context.Response.ContentType = "application/json"; context.Response.Write(callback + "(" + jsonResult + ")"); context.ApplicationInstance.CompleteRequest();