前端
$.ajax({
type: "get",
url: "http://baiduzd.yihu.com.cn/APIService.asmx/GetHospitalStatus",
dataType: "jsonp",
jsonp: 'callback',
data: { "HospitalID": 1111 },
success: function(result) {
//返回结果
alert(result.status);
},
error: function() {
//返回结果
alert("1111");
}
});
type: "get",
url: "http://baiduzd.yihu.com.cn/APIService.asmx/GetHospitalStatus",
dataType: "jsonp",
jsonp: 'callback',
data: { "HospitalID": 1111 },
success: function(result) {
//返回结果
alert(result.status);
},
error: function() {
//返回结果
alert("1111");
}
});
后端
[WebMethod]
[ScriptMethod(UseHttpGet = true,ResponseFormat = ResponseFormat.Json)]
public void GetHospitalStatus(string HospitalID)
{
string strStatus = GetHospitalInfo.GetHospitalStatus(HospitalID);
HttpContext.Current.Response.Write(HttpContext.Current.Request["callback"] + "({'status':" + strStatus + "})");
}