處理get請求后返回json的求教?
新建建Web服務頁面(*.asmx)
函數如下:
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
js調用如下:
$.ajax({
type: "POST",
url: "/Webservice/test.asmx/HelloWorld",
data: "{'Product_ID':'" + ProductID + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
try {
//do something
} catch (e) {
}
},
error: function () {
return false;
}
});