ajax擷取不到新提交的資料解決思路

來源:互聯網
上載者:User
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提交評論並接受應答後再次請求重新整理還是?
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.