JQuery Ajax Request always returns error (PARSERERROR)

Source: Internet
Author: User
[JavaScript]   View plain copy print? $.ajax ({               type : "Post",                url : "Busine_ In.action ",               timeout :  40000,               data:  " Centerid= "+s,               error :  function (xmlhttprequest, textstatus, errorthrown)  {                         alert ( Xmlhttprequest.status);                           alert (xmlhttprequest.readystate);                            alert (textstatus);                    alert (' Read timeout, check network connection ');                },                dataType :  "JSON",                success : function (data) {                    alert ("1");                     $ ("#select_div "). Hide ();                      &nBsp; str= ' <div style= " overflow:auto;height:430px;" > ';                        str+= ' <table border= "0"  cellspacing= "0"  cellpadding= "0"   Width= "100%"  class= "table2 muma_list" > ';                        str+= ' <tr> ';                        str+= ' <th align= left ' > Area </th> ';                        str+= ' </tr> ';                    $.each ( Data,function (i, n) {   &NBSP;&NBSP;&NBSP;&NBSp;            alert ("2"); alert (i); Alert ("n==" + N.length);                     if  ("list"  == i) {                        str+= ' <tr> ';                         str+= ' <td><a href= ' Javascript:unitedit (\ ' +n.areaid+ ') " title=" click Edit ">" + N.areaname+ ' </a></td> ';                        str+= ' </tr> ';                     }                    });                        str+= ' </table> ';                         str+= ' </div> ';                        alert ("3");                        $ ("#select_div "). HTML (str);                }    &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP});   The above code has entered the error, and [JavaScript]View Plain copy print? alert (textstatus);

The pop-up is always parsererror [JavaScript] view plain copy print? alert (xmlhttprequest.status);

Eject 200 normal [JavaScript] view plain copy print? alert (xmlhttprequest.readystate);

Eject 4 Normal

Finally, the reason for the pop-up parsererror is a type problem, that is, the return type may be problematic. Sure enough, we found that the result return type in the action of the AJAX request in the Struts.xml file is not JSON

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.