jQuery ajax error:parserror

來源:互聯網
上載者:User

標籤:cti   stat   方法   auth   thrown   解決中文亂碼   其他   ext   jquer   

前端jQuery ajax(部分):

$.ajax({
type:"post",
dataType:‘json‘,
url:"http://localhost:8080/Authorization/UsernameConfirm.jsp",
data:{//傳參 
"username":$("#username").val(),
},
success:function(msg)

$("#showResult").html(msg);
$("#showResult").css("color","red");
},
error: function (jqXHR, textStatus, errorThrown) {
/*彈出jqXHR對象的資訊*/
alert(jqXHR.responseText);
//該部落格介紹: http://blog.csdn.net/zhu_xun/article/details/16843861
alert(jqXHR.status); 
//readyState :目前狀態,0-未初始化,1-正在載入,2-已經載入,3-資料進行互動,4-完成。
alert(jqXHR.readyState); 
alert(jqXHR.statusText); 
/*彈出其他兩個參數的資訊*/
alert(textStatus); 
alert(errorThrown); 
}
});

後端jsp處理:

<%
String username = request.getParameter("username");
response.setContentType("text/html;charset=utf-8");//解決中文亂碼
userService us = new userService();
if(us.confirmUsername(username)==false){
response.getWriter().write("此使用者名稱已存在");
}
else {
response.getWriter().write("您可以使用此使用者名稱");
}
%>

之後前端ajax響應error函數,各參數的值為:

status:200  http ok

readyState  4 完成

statusText   paserror 解析錯誤

解決方案:去掉      dataType:‘json‘

jQuery ajax error:parserror

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.