The reason why Jquery Post does not enter the callback and the solution, jquery callback

Source: Internet
Author: User

The reason why Jquery Post does not enter the callback and the solution, jquery callback

Today, I made a simple addition of data. I uploaded the Json data to the Jsp background using the Post method of Jquery, but I didn't go into the callback function after processing it,

$. Post ("addGs. do "," x = "+ JSON. stringify (x), function (d) {alert ('success') ;}, "json ");

Through FF debugging, it is found that the returned data is normal, 200Ok,

No way. Let's look at Jquery API. If the final parameter is Json, the returned data must be in Json format,

Is the returned Json not standard?

Note that Json usually requires double quotation marks for both Key and Value,

Change code now

Try {d. add (gs); out. println ("{\" s \ ": \" OK \ "}");} catch (Exception e) {out. println ("{\" s \ ": \" err \ "}"); e. printStackTrace ();}

This time finally succeeded.

In Json mode, the Post method must be in strict Json format to enter the callback. If the Text method is used, there is no such requirement.


Thank you for the callback function of JQuery's post method.

No.
No callback will be performed unless you do not go in.
Send it to me

Jquery post method callback function not executed

$. Post ('ershou/login! Login. action', {'petname': username, 'Password': password}, function (data) {alert (data );})

In this way ~ The format is
$. Post (url, {parameter list}, function (){})

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.