I was calling a [web method] using POST but as I am 'getting' data back I am trying to use GET instead.
Using Post works. Using GET gives me a 500 error.
This is the main jquery call to my [web method]:
$.ajax({
type: 'GET',
contentType: 'application/json',
dataType: 'json',
url: 'Cloud/Feed.aspx/GetNextFrames2',
data: '{ test: "hime"}',
~
This is my test [web method].
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static string GetNextFrames2(string test)
{
return 'test'
}
If I do not pass any parameters I will get no error using GET. As soon as add a parameter I get 500 internal error.
I have used wireshark and Fiddler but I cannot see anything useful.
This is obviously down to using parameters. So, at least I have pinpointed where the error is.
I have tried passing the parameters directly appended to the url:
myurl?par=testme...
but still same error.
What else can I try?
Thanks
The problem is with the value in the query string. The value should be within quote. The below code is working.
$.ajax({
type: 'GET',
contentType:'application/json',
dataType: 'json',
cache:false,
url: "TestWebMathod.aspx/GetNextFrames2?test='hime'",
error: function (error) {
alert(error.responseText)
},
success: function (result) {
alert(result.d)
}
});
Also look at the error.responseText to know the exact exception message. This will help to resolve the error.