webservice jsonp格式调用

前端

 $.ajax({
            type: "get",
            url: "webservice jsonp格式调用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 + "})");
}

上一篇:PBR下一跳类型研究


下一篇:cmd界面的编码如何改为utf8