[JavaScript]View PlainCopyprint?
- $.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, please check network connection ');
- },
- DataType: "JSON",
- Success: function (data) {
- Alert ("1");
- $ ("#select_div"). Hide ();
- 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) {
- 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);
- }
- });
The code above always goes into error, and
[JavaScript]View PlainCopy print?
- alert (textstatus);
The pop-up is always parsererror.
[JavaScript]View PlainCopyprint?
- alert (xmlhttprequest.status);
Eject 200 Normal
[JavaScript]View PlainCopy print?
- 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)