且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从javascript调用webmethod时ASP.NET 500内部服务器错误

更新时间:2022-06-13 09:08:07

首先,如果web方法在页面类中,而不在Webservice类中,则它应该是静态的.

First, it the webmethod is in the page class, and not in a Webservice class, then it should be static.

第二,传输的数据实际上不是字符串,而是对象,因此将其更改为:

Second, the data transfered is not really a string, but an object, so change it to:

var dataString = { 'value':  value  };

第三件事,类型"用于旧版本的jquery,您应该将ajax调用更改为:

Third thing, "type" is for older versions of jquery, you should either change your ajax call to:

method: "GET",
url: pagePath,
data: dataString,
contentType: "application/json; charset=utf-8",
dataType: "json",...

或通过删除

UseHttpGet = true