javascript - asp.net Ajax submit event displays the json result returned from controller instead of alert -


i have view contains javascript code submit data controller

the data processed @ controller page display json result returned controller instead of alert. idea ?

here code

<code> @using (@html.beginform()) {    //some thing  <input id="btsavedetails" type="submit" name="btnsave" value="save" />  }  javascript <script type="text/javascript">     $("#btsavedetails").submit(function (e) {         $.ajax({             type: "post",             cache: false,             async: true,             url: '@url.action("groups", "user")',             data: $('form').serialize(),             datatype: "json",             success: function(response) {                 alert(response.status);             },             error: function (xmlhttprequest, textstatus, errorthrown) {                 if (errorthrown == "forbidden") {                     alert("forbidden access");                 } else {                     alert('an error occurred please retry.');                 }             }         });     });  </script>  controller :      public jsonresult groups(groupsmodel usergroups)         { //some processing  return json(new { status = "saved" }); } </code> 

thanks

i changed html.beginform helper follows,

please try , let me know.

<pre> <code><script src="~/scripts/jquery-1.8.2.min.js"></script> @using (@html.beginform("groups", "user")) {    <input type="text" /> <input id="btsavedetails" type="submit" name="btnsave" value="save" /> }  <script type="text/javascript"> $("#btsavedetails").submit(function (e) {     $.ajax({         type: "post",         cache: false,         async: true,         url: '@url.action("groups", "user")',         data: $('form').serialize(),         datatype: "json",         success: function (response) {             alert(response.status);         },         error: function (xmlhttprequest, textstatus, errorthrown) {             if (errorthrown == "forbidden") {                 alert("forbidden access");             } else {                 alert('an error occurred please retry.');             }         }     }); }); 

and modified success response follows

how convert json object string in alert box?


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -