c# - Calling asmx web service using JQuery with parameters causes 500 error -
i have simple plenty web service:
[scriptmethod(usehttpget = true, responseformat = responseformat.json)] [webmethod] public string gettoken(string a) { }
and i'm calling client side using jquery:
$.ajax({ post: 'get', contenttype: "application/json; charset=utf-8", datatype: 'json', url: '../url/gettoken', data: "{'a':'test'}", success: function (data) { }, error: function (a, b, c) { } });
the phone call fails , error returned 500 internal server error. have placed breakpoint within web service, , code isn't beingness reached @ all. when modify web service take no arguments @ (and remove data
element jquery call) phone call succeeds. have played around different ways pass data
element; i've passed json object (no quotes), , i've removed quotes around a
argument. none of works.
using fiddler have determined actual error causing 500 "invalid web service call, missing value parameter".
edit 2:passing info way works:
data: "a='test'"
i have no thought why. ideas?
haven't tested this, in code snippet have post: 'get'
rather type: 'get'
. may causing server reject contenttype json (which why info isn't beingness serialized properly).
c# web-services jquery asmx
No comments:
Post a Comment