使用jquery的Ajax时表单提交不起作用
如果提交按钮(secondbutton)来自使用jquery的ajax页面(ajax.php),则该按钮不起作用。在某些浏览器中,它运行良好。但是,在某些浏览器中,例如像某些移动浏览器一样无法工作。请帮我做使用jquery的Ajax时表单提交不起作用,jquery,ajax,Jquery,Ajax,如果提交按钮(secondbutton)来自使用jquery的ajax页面(ajax.php),则该按钮不起作用。在某些浏览器中,它运行良好。但是,在某些浏览器中,例如像某些移动浏览器一样无法工作。请帮我做 <!DOCTYPE html> <html lang="ta"> <head> <script src="https://ajax.googleapis
<!DOCTYPE html>
<html lang="ta">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#MyRegister").on('submit', function(){
if ($("#Button").val()=="FirstButton") {
$.ajax({
url: "Ajax.php",
method: "GET"
})
.done(function(response) {
$("#Opj").html(response);
});
return false;
}
return true;
});
</script>
</head>
<body>
<form id="MyRegister" method="post" action="Target.php">
<input id="MyName" type="text">
<div id="Opj"> <input type="submit" id="Button" value="FirstButton"></div>
</form>
</body>
</html>
$(文档).ready(函数(){
$(“#MyRegister”)。在('submit',function()上{
if($(“#按钮”).val()=“第一按钮”){
$.ajax({
url:“Ajax.php”,
方法:“获取”
})
.完成(功能(响应){
$(“#Opj”).html(回复);
});
返回false;
}
返回true;
});
Ajax.php
<input type="submit" id="Button" value="SecondButton">
我认为您必须将新按钮绑定到表单上,就像您的JS中的答案一样。您的JS有几个语法错误,请在重试之前尝试修复它们。如果缩进简洁,您将很容易发现语法错误
清除代码:
$(document).ready(function(){
$("#MyRegister").on('submit', function(){
if ($("#Button").val()=="FirstButton") {
$.ajax({
url: "Ajax.php",
method: "GET"
})
.done(function(response) {
$("#Opj").html(response);
});
return false;
}
return true;
});
不,这是不同的问题。但这里我只有一个表单。但是第二个按钮不起作用,它来自Ajax。phpi已经在您的帮助下编辑了这个问题。但是它在某些浏览器中仍然不起作用。您能帮我更多的忙吗。您能详细介绍一下“某些浏览器”吗?您还收到了哪些错误?Secondbotton收到的操作没有什么。by secondbutton无法提交表单。您能帮我做些什么吗?