我用jquery的ajax请求struts2的Action,Action收到数据,处理后返回,但是ajax收不到返回数据,执行了error回调函数,打印出来的status是0.texterror是error,哪位有经验的朋友知道这样的情况一般会是什么原因引起的。
应该不是啥写错的一些低级错误,因为同样的代码结构我前面的都可以正常请求,这一个突然就不行了。请解说一下。
$.ajax({
url: getRootPath() + '/merchant/shop!toEdit',
type : 'Post',
cache : false,
dataType : 'html',
data:{
},
success : function(d) {
alert(d);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.responseText);
alert(XMLHttpRequest.readyState);
alert(textStatus);
}
public String toEdit() throws Exception{
merchant = (Merchant)getSession().getAttribute("merchant");
shop = shopService.queryByMerchant(merchant.getId());
return "toEdit";
}
<action name="shop" class="com.baidu.web.merchant.action.ShopAction">
<result name="toEdit">/WEB-INF/pages/editShop.jsp</result>
</action>
ajax
struts2
error
status?==?0
------解决方案--------------------
浏览器直接访问getRootPath() + '/merchant/shop!toEdit'
这个地址有输出吗,同时用chrome开发工具看发送xhr返回了什么内容