Sencha Touch Ajax 请求调用了两次
sencha touch ajax request called twice
我的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);
}
});
但是,请求被发送到服务器两次。
-点击事件肯定只触发一次!
-如果我手动浏览到 strURL 中的 URL,服务器端函数只触发一次,因此它似乎不是服务器端的任何内容。
但是(相同,除了 url)应用程序中其他地方的 ajax 请求只触发一次,我看不出有任何区别!
我该如何追踪?
我可以通过在服务中将重定向到 doPost 从 doGet 来重现该行为,例如:
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 方法,但我现在想不起了。话虽如此,你的servlet不会运行两次,而是同时运行doGet和doPost。
相关文章:
- Meteor Router数据函数被调用两次
- 从MySQL数据库中获取输入数据需要两次页面刷新
- Module.start()已激发两次
- Jquery点击事件必须点击两次
- Append元素在运行两次函数后不显示
- 防止双击执行两次jQuery post请求
- 我必须点击两次才能激活任何按钮操作(离子/角度)
- 单击jQuery会激发两次
- 如何避免在树上走两次
- button.单击两次删除附加操作后不工作
- 由于$compile,Javascript(Angular)嵌套指令加载了两次
- 单击元素两次后执行操作
- AngularJs正在阻止链接被点击两次
- 为什么我的路线处理程序会触发两次
- 为什么Highchart在我的rails应用程序中加载了两次?(未捕获的Highcharts错误#16)
- 在列表中至少使用两次随机生成的nr
- 检查某个键是否按下两次
- 一次点击,两次'单击'事件已启动
- 我的所有代码在使用Webpack编译时都会运行两次
- Sencha Touch Ajax 请求调用了两次