復制代碼 代碼如下:
getHellobyAjax: function(callabckFun) {
$.ajax({
type: "GET",
url: "WebService.asmx/HelloWorld",
//contentType: "application/json; charset=utf-8",
//data:"{}",
cache: false,
dataType: "json",
success: function(msg) {
if (callabckFun) {
callabckFun(msg);
}
else {
alert("Not exists callback function.");
}
},
error: function(obj, message) {
alert(message);
}
});
復制代碼 代碼如下:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld() {
return "Hello World";
}
復制代碼 代碼如下:
{"Message":"試圖使用 GET 請求調用方法“HelloWorld”,但不允許這樣做。","StackTrace":" 在 System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)/r/n 在 System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
復制代碼 代碼如下:
// true if the method is invoked by using the HTTP GET command; false if the
// method is invoked by using the HTTP POST command. The default is false.
新聞熱點
疑難解答
圖片精選