0

我使用下面的ajax发布

$('#myFormId').on('submit', function() {

    var form_data = {
        csrfsecurity: $("input[name=csrfsecurity]").val(),
        post_text: $('#post_text').val()    
    };

    $.ajax({
        url: "<?php echo site_url('/post_status'); ?>",
        type: 'POST',
        data: form_data,
        success: function(response){
            $(".home_user_feeds").html("markUpCreatedUsingResponseFromServer");
        }
    });
    return false;
});

当我发布某些内容并刷新页面时,浏览器会显示以下警报。

Confirm Form Resubmission

The page that you're looking for used information that you entred. Returning to that page might cause any action you took to be repeated.

如何摆脱它。

4

1 回答 1

0

首先尝试阻止默认表单事件:

$('#myFormId').on('submit', function(e) {

    e.preventDefault();

    var form_data = {
        csrfsecurity: $("input[name=csrfsecurity]").val(),
        post_text: $('#post_text').val()    
    };

    $.ajax({
        url: "<?php echo site_url('/post_status'); ?>",
        type: 'POST',
        data: form_data,
        success: function(response){
            $(".home_user_feeds").html("markUpCreatedUsingResponseFromServer");
        }
    });
    return false;
});
于 2013-03-04T19:56:30.253 回答