javascript - Server does not receive data from ajax call -


i have problem. i'm trying send content of textarea ajax call, doesn't seem working, , don't know why.

there's method called getstatus(string statustext) need receive content.

here's javascript code:

$("#btnsavestatus").on("click", function () {                     var statustext = $(".textareaedit").val();                      $.ajax({                         type: "get",                         url: "default.aspx/getstatus",                         data: "{statustext:'" + statustext + "'}",                         contenttype: "application/json; charset=utf-8",                         datatype: "json",                         success: function (result) { //                            $('#littlbioid').text(result.d);                         }                     });                 }); 

please advise. should know i'm new web development.

  1. you can't have request body in request, have use post request that
  2. the string constrcting not valid json since:
    • property names must strings
    • you have no idea user enter in textarea - might contain characters special meaning in json

generate json programatically.

{   type: "post",   url: "default.aspx/getstatus",   data: json.stringify({     statustext: statustext   }),   // etc 

obviously, server side of process needs set accept post request json body (instead of more standard url form encoded format) well.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -