admin管理员组

文章数量:1417070

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);
                },
            });

本文标签: get a bad request 400 on my ajaxadminphp file