2014-06-24 57 views
4

我有一个Phonegap Android应用程序的奇怪问题。我有一个按钮ontouchend='dosomeajax()'Phonegap应用程序意外重启

如果我通过远程检查控制台执行该功能一切顺利,但如果我点击按钮,该功能意外返回ajax错误,并重新启动(重新加载主html页面)。

D/com.appgyver.preview.ESWebViewClient(3632): shouldInterceptRequest: http://myserver.com/action.php 
D/com.appgyver.preview.ESWebViewClient(3632): onLoadResource: http://debug.phonegap.com/ws/target/112xxxxx4 
D/com.appgyver.preview.ESWebViewClient(3632): onLoadResource: http://myserver.com/action.php 
D/com.appgyver.preview.ESWebViewClient(3632): shouldOverrideUrlLoading: http://localhost/index.html, http://localhost/index.html? 
D/com.appgyver.preview.ESWebViewClient(3632): Overriding url loading for http://localhost/index.html? 

怎么了?

+0

给我们更多的见解。这个功能干什么?!也许你有一个表单提交按钮,默认事件是它在发送数据后重新加载页面。如果是这种情况,请使用jQuery中的e.PreventDefault来防止DOM元素的默认行为。让我们更新 –

回答

2

请告诉你如何声明按钮,如果是这样的:

<a href="#" ontouchend="dosomeajax()">click me</a> 

这可能是因为href触发页面重载。只要删除href或使其成为href="javascript:false;"左右。