我的Sencha Touch 2应用程序有几个地方,它通过点击按钮发出AJAX请求。这是相当标准的东西:sencha touch ajax请求被调用两次
console.log('Saving Billing Item at' + strURL);
Ext.Ajax.request({
url: strURL,
method: 'GET',
success: function (result, request) {
var resultJson = Ext.decode(result.responseText);
console.log('Response from Saving BillingItem:' + result.responseText);
data = Ext.decode(result.responseText);
if(data.ErrorMessage.indexOf("successfully") == -1) {
Ext.Msg.alert('Error!', 'Error saving Billing Item:' + data.ErrorMessage);
} else {
Ext.StoreMgr.get('BillingItemList').load();
Ext.ComponentManager.get('MainMenu').animateActiveItem(23, {
type: 'slide',
direction: 'right'
}); //back to list
}
Ext.ComponentManager.get('BillingItemSaveButton').setDisabled(false);
},
failure: function (result, request) {
Ext.Msg.alert('Error!', 'There was a problem while saving the Billing Item. Please check your input and try again.');
Ext.ComponentManager.get('BillingItemSaveButton').setDisabled(false);
}
});
然而,请求正在发送到服务器TWICE。
- 轻拍事件肯定只被解雇一次!
- 如果我手动浏览到strURL的URL,服务器端功能仅触发一次,因此它不看来是任何服务器端。
但是(相同,除了URL)的应用程序的其他地方Ajax请求只火一次,我看不出有什么区别!
我该如何去跟踪它?
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("In doGet");
doPost(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("In doPost");
}
结果为:
In doPost
In doGet
In doPost
我记得的东西是只适用于EXTJS POST方法
你是怎么知道Ajax请求被触发两次的?控制台上有任何o/p? –
该服务在服务器上被调用两次,每次该应用程序触发该事件一次。 – SteveCav
我也有同样的问题。你有没有找到解决办法? – Kapil