<script type="text/javascript">alert(111);$.ajax({ type: "GET",dataType:"text",url:"http://202.117.191.165/RestTest/services/getOtherLectures/getOtherLectures",data:{"serverip":"127.0.0.1"},contentType: "json", success:function(response){alert(response+"成功");},error:function(data) { alert(data,"error");}});</script>通過瀏覽器訪問直接訪問時,是可以進入到action中的,用傳統的ajax也可以返回結果。請大家分析一下是什么原因。
1 回答

三國紛爭
TA貢獻1804條經驗 獲得超7個贊
一直調用error方法,請求失敗時調用此函數。有以下三個參數:XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象。
如果發生了錯誤,錯誤信息(第二個參數)除了得到null之外,還可能是"timeout", "error", "notmodified" 和 "parsererror"。
參考如下:
$.ajax({
url : "/education2/json/getSearchQuestionknowledgeview",
type: "post",
data : params,
dataType : "json",
cache : false,
error : function(textStatus, errorThrown) {
alert("系統ajax交互錯誤: " + textStatus);
},
.....
調試停在alert("系統ajax交互錯誤: " + textStatus);處,然后在firebug右邊的監控窗口看"textStatus",展開看有詳細錯誤細節.errorThrown中有錯誤類型。
- 1 回答
- 0 關注
- 618 瀏覽
添加回答
舉報
0/150
提交
取消