sharpest

转自:https://blog.csdn.net/yiluoak_47/article/details/8190598###

[javascript] view plain copy print?

  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(\'读取超时,请检查网络连接\');  
  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">区域</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="点击编辑">\'+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.           });  

上述的代码一直进入error,并且

[javascript] view plain copy print?
  1. alert(textStatus);  

弹出的一直是parsererror

[javascript] view plain copy print?
  1. alert(XMLHttpRequest.status);  

弹出200正常

[javascript] view plain copy print?
  1. alert(XMLHttpRequest.readyState);  

弹出4正常

最后发现弹出parsererror的原因是类型的问题,也就是说可能是返回类型出问题了。果然进过查找,发现在struts.xml文件中的ajax请求的action中的result返回类型不是json


分类:

技术点:

相关文章:

  • 2021-11-05
  • 2021-05-02
  • 2021-11-05
  • 2021-05-24
  • 2021-11-24
  • 2021-12-16
  • 2021-09-07
  • 2021-10-14
猜你喜欢
  • 2021-09-25
  • 2021-11-05
  • 2019-03-05
  • 2021-11-05
  • 2021-11-24
  • 2021-12-04
  • 2021-08-07
相关资源
相似解决方案