Php 带有警报的AJAX提交功能不起作用
我正在尝试让ajax提交功能正常工作。我找不到这里有什么问题。提交按钮位于表单中的表中 我尝试使用alert查看它是否工作,但它仍然不工作 方法-Php 带有警报的AJAX提交功能不起作用,php,jquery,ajax,Php,Jquery,Ajax,我正在尝试让ajax提交功能正常工作。我找不到这里有什么问题。提交按钮位于表单中的表中 我尝试使用alert查看它是否工作,但它仍然不工作 方法- $("#submit").submit(function(){//comparing the total quoted hours with duration of time selected alert("DEMO TEST"); // code for the comparing values goes h
$("#submit").submit(function(){//comparing the total quoted hours with duration of time selected
alert("DEMO TEST");
// code for the comparing values goes here but that's another
//story
});
“提交”按钮-
<input type="submit" name="submit" value="submit" id="submit" onclick="index.php">
显然,警报应该弹出一个带有演示测试的警报。
我不知道我哪里出错了你必须指出问题所在。提交到你的表格,而不是你的按钮。
关于提交如何在jQuery上工作的更多信息,因为您正在调用提交事件。当您调用提交事件时,您的表单将提交。你需要采取类似的id和class形式
<form action="" id="formsubmit">
<input type="submit" value="Submit"> //Remove name="submit" onclick="index.php"
</form>
$("#formsubmit").submit(function(){
alert("DEMO TEST");
});
//删除name=“submit”onclick=“index.php”
$(“#formsubmit”).submit(函数(){
警报(“演示测试”);
});
jQuery on click事件首先被触发为onclick=“index.php”,因此请删除它并提交表单,然后它就会工作。或者,如果希望触发该事件,则应返回true。或者您可以使用.submit()使用jQuery提交表单,提交表单后可以使用location.href很高兴为您提供帮助。