0
我有我的AJAX形式,它的工作很棒。 我每次提交表格时都会返回<div id="message"></div>
内的结果,但当我有多个表格时会变得复杂。所以我想知道如果他们是一种方式来表明内部形式什么<div>
返回消息。AJAX表单,传递返回消息
这里是我的AJAX.js
$("form#ajaxForm").on("submit", function() {
var form = $(this),
url = form.attr("action"),
type = form.attr("method");
data = {};
form.find("[name]").each(function(index, value){
var input = $(this),
name = input.attr("name"),
value = input.val();
data[name] = value;
});
$.ajax({
url: url,
type: type,
data: data,
success: function(response) {
$("#message").html(response); //I would like to interactively switch the return div, from #message to like #message2
$("body, html").animate({
scrollTop: $($("#message")).offset().top - 5000
}, 600);
}
});
return false;
});
在我想指明返回DIV是,像
<form action="../forms/add_event_form.php" method="post" id="ajaxForm">
//Can I add an input somewhere here? To indicate where I want the return to go too? Like <input type="hidden" value="message2" name="return">
<input type="text" class="formI" name="date" id="dateI" placeholder="Date">
<input type="submit" name="submit" class="btn btn-primary" value="Add">
</form>
感谢您阅读此形式。祝你有美好的一天!并且预先感谢您的回复。