Home > Backend Development > PHP Tutorial > ajax获取不到新提交的数据解决思路

ajax获取不到新提交的数据解决思路

WBOY
Release: 2016-06-13 13:14:07
Original
931 people have browsed it

ajax获取不到新提交的数据
默认用ajax获取列表
$(document).ready(function() {
  get_pm(1);
});

// 获取信息
function get_pm(page)
{  
  var list = '';
  $.get(MODULE_URL + 'getpm', {"touid":touid, "page":page}, function(response){
  $.each(response.data, function(key, rows) {
  list += rows['content'];
  });
  $(".weibo_list").html(list);
}

// 表单提交函数
function save()
{
  var fromuid = $('#fromuid).val(); 
  var msgto = $('#msgtoid').val();
  var content = $('#content').val();
  var replyid = $('#replyid').val();
  var image = $('#image').val();
  $.post(MODULE_URL + 'dosend', {"fromuid":fromuid, "msgto":msgto,"replyid":replyid, "content":content, "image":image}, function(response){
  if (response.error_code > 0)
  {
  alert(response.msg+'('+response.error_code+')');
  }
  else
  {  
  $('.send_success').show();
  get_pm(1);
  setTimeout(hide_success, 2000);
  }
  }, 'json');
}
 
// 隐藏发送成功div
function hide_success()
{
  $('.send_success').hide();
  // location.reload(); 
}

现在问题是:
我表单提交成功时调用了get_pm(1);应该是重新请求了数据,
表单提交成功了,数据也加到数据库了,但是新的数据无法显示出来,必须刷新下页面才行,不知道是怎么回事?
是ajax哪里用错了吗?

------解决方案--------------------
你有
$(document).ready(function() {
get_pm(1);
});
刷新当然可以,但这就不是ajax了

ajax提交的回调函数中有 get_pm(1);
按理应该有效的,但我怀疑并没有执行到
------解决方案--------------------
是否有主从问题导致的同步慢问题?
Ajax提交评论并接受应答后再次请求刷新还是?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template