最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

get a bad request 400 on my ajax-admin.php file

programmeradmin1浏览0评论

I've been working on ajax lately. The tutorials you find on the net are all very similar and quite easy to implement. But I always get a bad request 400 on my ajax-admin.php file. also wp_localize_script used properly with wp_ajax action. when i logged in with Administrator.it works fine. getting 400 with other role.

var file_data = $('#file').prop('files')[0];
            var form_data = new FormData();
            form_data.append('file', file_data);
            form_data.append('action', 'file_upload');

$.ajax({
                url: ajaxurl,
                type: 'POST',
                processData: false,
                data: form_data,
                dataType: "html",
                contentType: "application/json",
                success: function (response) {
                    alert(response);

                },
                error: function(e) {
                    console.log(e);
                },
            });
发布评论

评论列表(0)

  1. 暂无评论