成功的Ajax帖子后,我希望使用JQuery的.load()方法呈现处理程序中与POST关联的模板。 GET请求在POST成功后不断被调用...所以与GET相关的模板得到渲染,而不是与POST关联的模板。感谢您提供的任何提示。ajax post成功后,如何使用JQuery .load()方法发送POST请求
的Javascript:
$(function() {
$(".topic_submit").click(function() {
var topic = $("#topic").val();
refresh = 'false'
$.ajax({
type: "POST",
url: "/mentorlist",
data: {'topic': topic},
success: function(dataString) {
$('#mentor_list').load('/mentorlist');
console.log('**mentor_list div updated via ajax.**');
}
});
return true;
});
});
HTML表单:
<form id="topic_search_form" name="topic_search_form" action="">
Topic: <input id ="topic" type="text" name="topic" size="60" placeholder="Search by Keyword" />
<input type="submit" class="topic_submit" name="topic_submit" value="Search" >
这是不正确的。 'load()'仍然可以发起'POST'请求。看到http://api.jquery.com/load/ – haim770
我特别说'当你以这种方式调用.load()而没有额外的数据'。是的,如果您提供了其他参数,您可以发布帖子。 –
你是对的。抱歉。 – haim770