<form action="form.php">
<input type="text" name="email">
<input type="text" name="pass">
<input type="submit">
</form>
<script src="jquery.js"></script>
<script>
$("form").on("submit",function() {
$.ajax({
url: 'http://somewhere.org/login.php',
type: 'GET',
data: 'Data written to File',
success:function(response){}});
});
</script>
好的,这是问题所在,我在Opera上运行了这个代码运行脚本和表单的动作,成功了..但是在Qwebview上它只运行脚本而不是表单,为什么会这样?我尝试评论脚本,但表单仍然无效。
答案 0 :(得分:0)
包含ajax的表单需要return false;
在$.ajax
使用error
事件中获取错误。
示例:
$("form").on("submit",function() {
$.ajax({
url: 'http://somewhere.org/login.php',
type: 'GET',
data: 'Data written to File',
success:function(response){
//Something...
},
error:function(a, b, c){
alert([a, b, c]);//Get error
}
});
return false; //Prevent reload page
});