我的 phonegap HTML 页面中有一个按钮,我在其中添加了一个按钮单击事件和对 Web 服务 URL 的 ajax 调用。目前我没有调用任何 Web 服务 URL,但我遇到的主要问题是我的按钮单击事件没有被解雇。在 logcat 上它给出以下错误..
stale touch event action_down received from webcore ignoring
这是我的按钮 HTML 代码..
<div style="display: table; margin: 0 auto; background-color: green;">
<button id="call" class="button">Call</button>
</div>
这是我的按钮点击事件的js文件代码..
//Add event listener to run when the device is ready
document.addEventListener("deviceready", onDeviceReady, false);
//Device is ready
function onDeviceReady() {
$(document).ready(function(){
$('#call').bind('click',function(evt){
senddata();
});
});
}
function senddata(){
e.preventDefault();
var empname=$("#name").text();
alert(empname);
var contactno=$("#contact").text();
alert(contactno);
//Webservice URL
var URL="index.html";
$.ajax({
url: URL,
data: "",
type: 'POST',
success: function (resp) {
alert(resp);
},
error: function(e) {
alert('Error: '+e);
}
});
}
请帮我解决这个问题..谢谢..
最佳答案
代替 bind()
只需使用以下内容:
$(document).on('click', '#Login_button', function() {
//Call your method to call webservice.
senddata();
}
或其他向按钮添加点击事件的方法如下:
<button id="call" onclick="senddata();">Call</button>
关于android - Android Phonegap 应用程序中的按钮单击事件出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27009706/