【发布时间】:2016-03-03 12:07:39
【问题描述】:
我有两种发布方法,一种是获取信息,另一种是向同一个数据库添加信息。 现在我希望其他发布方法在为其添加新数据后获取信息。 这是我的第一个 POST 方法:
$(".selectedMessageEmail").click(function(){
var id = $(this).attr('id');
$.post('messageSystem.php', {id, id}, function(result){
$("#rightBody").html(result);
});
show = id;
});
这是我的第二个 POST 方法:
$("#replyButton").click(function(){
var getValue = $.trim($("#sendMessageTextArea").val());
if(getValue != ""){
$.post('messageReplySystem.php', {replyMessagePost : reply_form.send_message_text_area.value, show : show}, function(resultTwo){
$("#sendMessageTextArea").val("");
});
}
});
换句话说,如何只在一个 div 中显示更新的数据库信息,而不刷新整个页面,也不复制我的代码。
【问题讨论】:
-
您可以将需要复制的代码包装在一个函数中,然后只使用该函数两次...无论如何我都会这样做。