i trying send data javascript aspx webmethod ajax. success option of ajax post fired web method never getting called. javascript code is:
$.ajax({ type: "post", url: '../about.aspx/getwfdata', data: "{senddata: '" + 5 + "'}", async: true, success: function (result) { alert("bravo"); }, error: function (jqxhr, textstatus, errorthrown) { alert(textstatus); alert(errorthrown); } }); and webmethod in code behind is:
[webmethod] public static string getwfdata(string senddata) { return string.format("hello"); }
try use below code see if works.
var params = '{senddata:' + values + '}'; $.ajax({ type: "post", url: '../about.aspx/getwfdata', data: json.stringify(params), async: true, success: function (result) { alert("bravo"); }, error: function (jqxhr, textstatus, errorthrown) { alert(textstatus); alert(errorthrown); } }); and refer http://elegantcode.com/2009/02/21/javascript-arrays-via-jquery-ajax-to-an-aspnet-webmethod/ more info. try disable request validation on page.http://www.asp.net/whitepapers/request-validation
Comments
Post a Comment