Reputation: 15925
I have a web-service which works fine using POST when communicating with it using ajax:
Client-side:
...
$.ajax({
url: 'webservice.asmx/GetCount',
type: 'POST',
data: '{"theDate": "' + strDate + '"}',
...
Server-side:
...
[WebMethod()]
public double GetCount(string theDate)
{
...
How would I go about converting these so they make use of GET
instead of POST
?
I've tried changing the client-side part to type: 'GET'
, but that gave an error so I am assuming I need to make some changes to the server-side part too?
Upvotes: 0
Views: 294
Reputation: 68410
You'll need to add [ScriptMethod(UseHttpGet=true)]
to your webmethod
Client-side:
...
$.ajax({
url: 'webservice.asmx/GetCount',
type: 'GET',
data: '{"theDate": "' + strDate + '"}',
...
Server-side:
...
[WebMethod()]
[ScriptMethod(UseHttpGet=true)]
public double GetCount(string theDate)
{
...
Upvotes: 1
Reputation: 344
Try adding the following attribute to the method in question. I believe this should work:
[ScriptMethod(UseHttpGet=true)]
Upvotes: 1