javascript - jsonp with asmx error 500 -
when try works perfact
function test() { debugger; $.ajax({ url: "http://testweb.com/myapi.asmx/getpersontest", type: "get", contenttype: "application/json; charset=utf-8", data: { userid: 1 }, datatype: "jsonp", success: function(json) { alert(json.userid + ' ' + json.firstname + ' ' + json.lastname); }, error: function() { alert("hit error fn!"); } }); }
in same asmx, have method called below
function post_test(){ var newurl = window.location.protocol + '//' + window.location.host + '/' + window.location.pathname; var user = document.getelementbyid('username').value; var email = document.getelementbyid('email').value; debugger; $.ajax({ url: "http://testweb.com/myapi.asmx/getperson", type: "get", contenttype: "application/json; charset=utf-8", data: json.stringify({ username: user, emailid: email}), datatype: "jsonp", success: function(json) { alert(json.userid + ' ' + json.firstname + ' ' + json.lastname); }, error: function(json) { alert("hit error fn!"); } }); }
this method insert database , return same getpersontest. when call through javascript , jsonp gives 500 server error
when check in debugger , gives below error
jquery17106155389654450119_1401518867750({"message":"invalid web service call, missing value parameter: \u0027username\u0027.","stacktrace":" @ system.web.script.services.webservicemethoddata.callmethod(object target, idictionary`2 parameters)\r\n @ system.web.script.services.resthandler.invokemethod(httpcontext context, webservicemethoddata methoddata, idictionary`2 rawparams)\r\n @ system.web.script.services.resthandler.executewebservicecall(httpcontext context, webservicemethoddata methoddata)","exceptiontype":"system.invalidoperationexception"});
can please me on below. thanks
the head of method
<webmethod(true)> _ <scriptmethod(usehttpget:=true, responseformat:=webmessageformat.json)> _ public function getperson(byval username string, byval emailid string) string end function
and when check header in developer tool below
callback:jquery17106155389654450119_1401518867750 {"username":"testuser","emailid":"test@test.com"}: _:1401518889467 response headersview source
please check parameter username being used in mentioned contract method. because, error showing missing of username parameter.
ensure , post reply soon.
Comments
Post a Comment