Call asp.net web method with parameters from jquery errors

I managed to install a simple web method that I called from jquery and of course it returns ... then I added parameters to this method and added parameters to jquery, but these are errors with

Message":"Invalid JSON primitive: one.","StackTrace":" 

my signature on my web method is like

  [WebMethod] public static string GetDate(string one, string two) { return "yes"; } 

and my jquery like this, what am I doing wrong?

  $.ajax({ type: "POST", url: "MyService.aspx/GetDate", data: { one: "value", two: "value" }, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { alert(msg.d); }, error: function(msg) { alert('error'); } }); 
+1
source share
1 answer

Try enclosing your data parameter in quotation marks:

 data: '{ one: "value", two: "value" }', 
+4
source

All Articles