ASP.NET 500 Internal Server Error while calling webmethod from javascript
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 };
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",...
Or change the function in the server side to get post calls, by removing the
UseHttpGet = true
Probably you need to add static to your method declaration as below
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public static string getUsername(string value)
{
return "True";
}
if this isn't the case, you could F12 the browser->network then click on the error message to see it briefly.
Concerning the reported issue,the problem with get request, try to make it post
The Answer is here :link
the problem is with the annotation I was using the [ScriptMethod(UseHttpGet = true)]
which causing the error. just change the value from true to false.