为什么发布至weblogic上总是进入error?

用jquery的ajax做了一个联动的下拉列表,在tomcat中一切正常,但发布到weblogic上后,后台方法执行正常,但前台总是进入error方法,alter(e.message)显示undefined,搞了一晚上,彻底崩溃,请高手们给予指点,O(∩_∩)O谢谢!

代码如下:

var url = "<%=request.getContextgPath%>/testAjax/doAjax.so?id=" + id;

$(function(){

    url:url,

    type:'post',

    dataType:'json',

    async:true,

    cache:false,

    success:function(data){

       alert(data); 

   },

   error:function(e){

       alert(e.message);

   }

})


江户川乱折腾
浏览 134回答 2
2回答

互换的青春

(1)error属性的使用方式是不是有问题,第一个参数jqXHR,是不是没有message属性,正确使用并打印出错误信息可能对问题分析有帮助。以下为jquery api的说明:errorType: Function( jqXHR jqXHR, String textStatus, String errorThrown )A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event.(2)怀疑:datatype属性,不知道你在服务端是怎么处理json返回的,返回的时候weblogic和tomcat会不会有不一致的地方;

守候你守候我

你写错了吧:是 $.ajax 而不是 $(function(){$.ajax({ url: "XXXX", success: function(){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }});
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JQuery