JQuery Ajax Request always returns error (PARSERERROR)

Source: Internet
Author: User

[JavaScript]View PlainCopyprint?
  1. $.ajax ({
  2. Type:"POST",
  3. URL:"busine_in.action",
  4. timeout:40000,
  5. Data: "centerid=" +s,
  6. Error: function (XMLHttpRequest, textstatus, Errorthrown) {
  7. alert (xmlhttprequest.status);
  8. alert (xmlhttprequest.readystate);
  9. alert (textstatus);
  10. Alert (' Read timeout, please check network connection ');
  11. },
  12. DataType: "JSON",
  13. Success: function (data) {
  14. Alert ("1");
  15. $ ("#select_div"). Hide ();
  16. str=' <div style= "overflow:auto;height:430px;"  > ';
  17. str+=' <table border= "0" cellspacing= "0" cellpadding= "0" width= "100%" class= "Table2 muma_list" > ";
  18. str+=' <tr> ';
  19. str+=' <th align= "left" > Area </th> ';
  20. str+=' </tr> ';
  21. $.each (data,function (i, n) {
  22. Alert ("2"), alert (i), alert ("n==" +n.length);
  23. if ("list" = = i) {
  24. str+=' <tr> ';
  25. str+=' <td><a href= "javascript:unitedit (\ ' +n.areaid+' \ ')" title= "click Edit > ' +n.areaname+'  </a></td> ';
  26. str+=' </tr> ';
  27. }
  28. });
  29. str+=' </table> ';
  30. str+=' </div> ';
  31. Alert ("3");
  32. $ ("#select_div"). html (str);
  33. }
  34. });

The code above always goes into error, and

[JavaScript]View PlainCopy print?
    1. alert (textstatus);

The pop-up is always parsererror.

[JavaScript]View PlainCopyprint?
    1. alert (xmlhttprequest.status);

Eject 200 Normal

[JavaScript]View PlainCopy print?
    1. alert (xmlhttprequest.readystate);

Eject 4 Normal

Finally, the reason for the pop-up parsererror is the type problem, which means that the return type is faulty. Sure enough, the result return type in the action of the AJAX request in the Struts.xml file was found to be not JSON

JQuery Ajax Request always returns error (PARSERERROR)

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.