2012-06-08 72 views
0

我的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方法

+0

你是怎么知道Ajax请求被触发两次的?控制台上有任何o/p? –

+0

该服务在服务器上被调用两次,每次该应用程序触发该事件一次。 – SteveCav

+0

我也有同样的问题。你有没有找到解决办法? – Kapil

回答

0

我可以把重定向的doPost从的doGet在我的服务,如重现行为但我现在不记得它。话虽如此,你的servlet不会运行两次,但同时运行doGet和doPost。

+0

很久以前,我从Sencha搬到了那里,但感谢您的洞察力。希望其他人会发现它有帮助。 – SteveCav

相关问题