Differences between the jquery version and the JSON Data Format

Source: Internet
Author: User

In the future, we chose jquery as the registration page. I don't know what version jquery is now. The JS Code I wrote references jquery1.3.2, while Comrade wheat uses jquery1.4.2 for the static interface. A problem was found during use. In versions 1 and 3.2, the success function can be responded, but in version 1.4.2, the success function is not responded, and the error function is returned. I searched the internet to find out that it was a version issue!

In Versions later than 1.4, the format of JSON returned data must be:

Code:
  1. After query 1.4, the JSON format is changed to strict.
  2. The {"key": "value", "key": "value"} must be in this format "};
  3. Like the original
  4. {Key: value, key: Value}
  5. {'Key': 'value', 'key': 'value '}
  6. This is all incorrect and not standard, so jquery Returns Error

Jquery

Code:
  1. $. Ajax ({
  2. Type: "Post ",
  3. URL: '/ZZB/register/register_check.jsp ',
  4. Cache: false,
  5. Datatype: 'json ',
  6. Data: {nickname: $ ("# nickname"). Val ()},
  7. Success: function (result ){
  8. Alert ('success '); 
  9. },
  10. Failure: function (result ){
  11. // Console. Log (result );
  12. },
  13. Error: function (){
  14. Alert ('error ');
  15. }
  16. });


Discussion: http://topic.csdn.net/u/20100310/17/4278ccd1-c5b4-41af-975e-65fba61ba00d.html

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.