dojo.Post提交数据,火狐提交不了,似乎是在按了button之后执行了默认行为,但是我明明禁止了。
rt程序代码:
<body> <center> <form id="registForm" method="post"> <table> <tr> <td><label for="name">手机号:</label></td> <td><input dojoType="dijit.form.TextBox" type="text" id="name" name="name"/></td> </tr> <tr> <td><label for="nickname">昵称:</label></td> <td><input dojoType="dijit.form.TextBox" type="text" id="nickname" name="nickname"/></td> </tr> <tr> <td><label for="password">密码:</label></td> <td><input dojoType="dijit.form.TextBox" type="password" id="password" name="password"/></td> </tr> <tr> <td><label for="password-2">确认密码:</label></td> <td><input dojoType="dijit.form.TextBox" type="password" id="password-2"name="password-2"/> </td> </tr> <tr> <td><label for="email">e-mail:</label></td> <td><input dojoType="dijit.form.TextBox" type="text" id="email" name="email"/></td> </tr> </table> <div id="passWdError" class="error"> </div> <button dojoType="dijit.form.Button" id="formBtn" onclick="sendForm()">提交</button> </form> </center> <script type="text/javascript"> function sendForm() { if(event && event.preventDefault) { //阻止默认浏览器动作(W3C) event.preventDefault(); event.stopPropagation(); } else { //IE中阻止函数器默认动作的方式 window.event.returnValue = false; window.event.cancelBubble = true; } var datatopost= { "name":""+document.getElementById('name').value, "nickname":""+document.getElementById('nickname').value, "password":""+document.getElementById('password').value, "email":""+document.getElementById('email').value }; var kw = { postData:dojo.toJson(datatopost), url: "http://localhost:8080/mm/rest/register", //表单要提交到的URL handleAs:"json", //返回值的处理方式 headers: {"Content-Type": "application/json; charset=utf- 8","Accept":"application/json"}, load: function(response) { alert("Response from server:" + response.id +"-"+response.privacy_policy); }, error: function(error) { alert("An error occurred:"+error); }, timeout:5000//超时时间 }; dojo.xhrPost(kw); } </script> </body> </html>
请问这样有问题吗,该怎样解决?