使用POST方法

时间:2017-08-04 17:40:33

标签: jquery ajax laravel

我已经在post方法上加载了一个bootstrap模式,现在modal包含用户发表评论和一个表单,管理员也可以在这里发表评论/回复帖子。以下是附件图片

enter image description here

现在,当管理员发布评论时,弹出窗口应仅使用发布方法进行重新加载,如果我使用 GET 加载它,通过改变我的路线,但我想要使用POST加载。这是我用于ajax的代码。

function comment() {
    jQuery('#showModal').on('submit', 'form', function (e) {
        e.preventDefault();
        var propertyID = jQuery('#propertyID').val();
        jQuery.ajax({
            headers: {
                'X-CSRF-TOKEN': jQuery('meta[name="csrf-token"]').attr('content')
            },
            url: '/user/Property/postComment',
            type: 'POST',
            data: new FormData(this),
            processData: false,
            cache: false,
            contentType: false,
            timeout: 10000,
            beforeSend: function () {
                jQuery('#commentBtn').html('<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>');
            },
            success: function (data) {
                // jQuery('#showModal').load('/user/loadPropertyComments/'+propertyID);
                jQuery('.result').show();
                jQuery('.result').html(data);
                jQuery('#commentBtn').html('Post Comment');
            },
            error: function (data) {
                jQuery('.result').show();
                jQuery('.result').html(data);
                jQuery('#commentBtn').html('Post Comment');
            }
        });
    });
} jQuery(comment());

我给出了控制台错误,如果我尝试使用POST方法加载,表示不允许使用方法。我怎么能把它转换成POST,任何想法。

0 个答案:

没有答案
相关问题