复制代码 代码如下:
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.
新闻热点
疑难解答
图片精选