当前位置: 代码迷 >> Ajax >> jQuery中ajax应用json数据类型总是跳过success执行error语句
  详细解决方案

jQuery中ajax应用json数据类型总是跳过success执行error语句

热度:225   发布时间:2012-09-10 22:20:12.0
jQuery中ajax使用json数据类型总是跳过success执行error语句
js中代码:
JScript code
    $.ajax({
            type : "post",
            dataType:"json",
            async: true,
            url : "adddata_action.jsp",
            data : paras,
            success: function(data) {
                if(data.response=='success')
                {
                    alert(data.message);
                    $("#arrange_sheet").dialog("close");
                }else{
                    alert(data.message);
                }
                
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                alert("error");
                /*
                $("#dialog-message_failed").dialog("open");
                */
            }



adddata_action.jsp中返回数据语句:
  out.println("{\"response\":\"yes\",\"message\":\"信息录入成功!\"}");

求帮助啊!

------解决方案--------------------
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.responseText);

}
就明白错误信息了;
  相关解决方案