Wednesday, 15 April 2015

javascript - How to call an exception with post method (AJAX)? -


If the post method is unsuccessful, would I like to throw an exception and write error log? Actually if this method does not give any results, then I want to throw an exception and write the file.

Post method:

  $ Post ("ip.php", function {$ ("# ip") .val (data.ip); $ ("# country") .val (data.country); $ ('# campaign ID') Val (data.campaignID);}, "json");  

For the part of the question:

Post method is unsuccessful, then I would like to throw an exception (...)

you can request as a $ .post () request

or use instead, where there is a error option - the function to call the function that the request fails.
$ Ajax () your $ Post () will be equivalent to the method:

  $. Ajax ({type: "POST", url: "ip.php", datatype: 'json', success: work (data) {$ ("# ip") .val (data.ip); $ ("# country Val (data.country); $ ('# campaignID'). Val (Data.campaignID);}, Error: function (jqXHR / * object * /, textstats / * string * /, error thrown / object * /) {// Throw an error ... // console.log (type 'error of:' + textstats);},});  

For that part:

(...) Write an error log

This is not possible Because to execute any file with Javascript, this client is implemented in the browser, so it has no access to the server. Okay, how does this work?


No comments:

Post a Comment