【发布时间】:2012-06-08 03:34:53
【问题描述】:
我的 Sencha Touch 2 应用程序有几个地方可以在单击按钮时发出 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 请求只触发一次,我看不出有任何区别!
我该如何追踪?
【问题讨论】:
-
您是如何得知 Ajax 请求被触发两次的?控制台上有任何操作吗?
-
服务在服务器上被调用两次,每次应用触发事件一次。
-
我也有同样的问题。你找到解决办法了吗?
标签: javascript ajax sencha-touch-2