jquery mobile intel xdk app表单提交无效

时间:2015-10-30 09:46:53

标签: jquery forms intel-xdk

我正在创建一个jquery移动应用程序,其中包含一个将数据发布到在线服务器的表单。当表单中有一个action属性时,表单会正确提交并在提交页面上显示一条消息。虽然我附加了jquery以防止它导航到提交页面,如下所示。

<form data-ajax="false" id="codeVerification" method="post" action="http://domain.com/app.php">
    <div data-role="fieldcontain">            
        <label >Code</label>
        <input  type="text" placeholder="enter code" name="code" id="code"/>
    </div>
    <div data-role="fieldcontain">
        <button id="codeSubmit" >Submit</button>
        <input type="hidden" value="codeVerification" name="action"/>
    </div>     
</form>

这是我的测试jquery代码,以防止从导航到提交页面

$(document).ready ( function() {
    $("#codeVerification").on('submit', function(){
        alert('true');
        return false;
    });
});

我了解data-ajax="false阻止表单通过ajax提交。所以我再次尝试从表单中删除action属性,但它仍然无法正常工作。当在浏览器上执行此操作时,jquery代码可以工作,但不能在intel xdk中工作。

我可能做错了什么?

1 个答案:

答案 0 :(得分:0)

remove the action="http://domain.com/app.php" in <form> and then the alert will work, when u click submit, it is redirecting to http://domain.com/app.php so the event is not handled in javascript