c# - Alert Success or Error message for jQuery POST method -


I am using the following jQuery to save and save data:

  var Data = "sample data"; $ .post ('@ Url.Content ("~ / Student / SaveData"), {data: data} // I want a warning or error alert here   

This is my controller :

  public action SaveData (string data) {try to save the data // save logic // save the success signal // pass hold (exception pre) {// pass error signal} return See);}   

If the error message is successfully saved otherwise, I want to alert the message of success.

first using the wrong assistant instead of @ Url.Content You are required to use the @ Url.Action

  var data = "sample data"; $ AZ ("Url.Action" ("SaveData", "Student"), Type: "Go", Data: {Sample: Data} Success: Function (Res) {Warning ("Success" );}, Error: function () {warning ("failure");}});   

And your action will be:

  Pub Lime Action Result SaveData (string sample = "") {return content (sample); }    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -