使用ajax发送发布请求时,显示错误

时间:2018-10-06 07:51:22

标签: ajax

我正在使用此代码发送ajax请求,但显示400错误的请求错误。任何人都请告诉我这个错误。我完全被困住了。

谢谢。

 function bulk_setup_post_type() 
    {
        wp_enqueue_style( 'customstyle', plugins_url( 'admin/css/custom.css' , __FILE__ ) );
        wp_enqueue_script( 'customjs', plugins_url( 'admin/js/custom.js' , __FILE__ ) );
        wp_localize_script('customjs', 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php')));
    }

    add_action('wp_register_scripts', 'bulk_setup_post_type');



     add_action('wp_ajax_extract_upload_data', 'extract_upload_data');
     add_action('wp_ajax_nopriv_extract_upload_data', 'extract_upload_data');



function abc(file){
        if(file!='')
        {
            jQuery.ajax({
                url : ajax_object.ajax_url,
                type : 'POST',
                data : {
                    action : 'extract_upload_data',
                    path : file,
                },
                success : function( response ) {
                //console.log(response);

                    alert(response);


                }
            });
        }
        else{ alert('File ' + file + 'not found.');}
    }

1 个答案:

答案 0 :(得分:0)

我相信您的网址不包含域名

相关问题