[英]ajax not working on two different forms in same page
i have two ajax scripts this is first 我有两个Ajax脚本,这是第一个
$(document).ready(function()
{
$("#ajaxform").submit(function(e)
{
$("#simple-msg").html("<img src='loading.gif'/>");
var postData ="";
postData = $(this).serializeArray();
var formURL = $(this).attr("action");
alert("login");
$.ajax(
{
url : formURL,
type: "POST",
data : postData,
//success:function(data, textStatus, jqXHR)
success:function()
{
$("#simple-msg").html('<pre><code class="prettyprint"> Login Successfull </code></pre>');
window.location = "Dealer/PostPropertyAdvanceDetails.php?login=successfull";
},
error: function(jqXHR, textStatus, errorThrown)
{
$("#simple-msg").html('<pre><code class="prettyprint"> Wrong Username or password </code></pre>');
}
});
e.preventDefault(); //STOP default action
});
$("#simple-post").click(function()
{
$("#ajaxform").submit(); //SUBMIT FORM
});
});
</script>
this is second 这是第二
<script>
$(document).ready(function()
{
$("#ajaxformReg").submit(function(e)
{
$("#simple-msg1").html("<img src='loading.gif'/>");
var postData ="";
postData = $('#ajaxformReg').serializeArray();
var formURL = $('#ajaxformReg').attr("action");
alert("reg");
$.ajax(
{
url : formURL,
type: "POST",
data : postData,
//success:function(data, textStatus, jqXHR)
success:function()
{
$("#simple-msg1").html('<pre><code class="prettyprint"> Register Successfull </code></pre>');
window.location = "Dealer/PostPropertyAdvanceDetails.php?register=successfull";
},
error: function(jqXHR, textStatus, errorThrown)
{
$("#simple-msg1").html('<pre><code class="prettyprint"> please fill all the details </code></pre>');
}
});
e.preventDefault(); //STOP default action
});
$("#simple-post1").click(function()
{
$("#ajaxformReg").submit(); //SUBMIT FORM
});
});
</script>
one for login and one for register login works fine.but when i click register both ajax scripts are called one by one..i want only register ajax script. 一种用于登录,一种用于注册登录可以正常工作。但是当我单击“注册”时,两个ajax脚本都被一个一个地调用。.我只想注册ajax脚本。 i have used two different forms.
我使用了两种不同的形式。
检查所有div是否正确关闭,并确保未嵌套表格
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.