在Wordpress中从jQuery调用PHP脚本

I'm having trouble with understanding how php files are called with jQuery in Wordpress.

I'm trying to create a file uploader within Wordpress.

I want to call the php files called uploadifive.php and check-exists.php in the function below.

The console error is a 404 and the file isn't being reached, I've also noticed that jquery is appending the wordpress permalink into the url which is causing the 404.

How can call the php file without the permalink automatically appended to the path of the .php file?

 jQuery.noConflict();

  $('#file_upload').uploadifive
      ({
          'auto'             : false,
          'buttonText'       : 'Browse',
          'fileSizeLimit'    : '1024 MB' ,
          'multi'            : false,
          'queueSizeLimit'   : 1,
          'checkScript'      : 'check-exists.php',                
          'queueID'          : 'queue',
          'fileType'     [ 'video/3gpp'],
          'uploadScript'     : 'uploadifive.php',
          'onUploadComplete' : function(file, data) {window.location =    'upload_to_youtube/processing.php?' + data;}

         });
       });   

1) first way is call your processing.php file using Ajax

$('#file_upload').uploadifive
  ({
          'auto'             : false,
          'buttonText'       : 'Browse',
          'fileSizeLimit'    : '1024 MB' ,
          'multi'            : false,
          'queueSizeLimit'   : 1,
          'checkScript'      : 'check-exists.php',                
          'queueID'          : 'queue',
          'fileType'     [ 'video/3gpp'],
          'uploadScript'     : 'uploadifive.php',
          'onUploadComplete' : function(file, data) {//window.location =    'upload_to_youtube/processing.php?' + data;
              jQuery.ajax({
                url:PUTFILEURL,
                data:data,
                type:'POST',
                success:function(data){

                }
            });


          }

  });

2) for WordPress Ajax API https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)

jquery code

 var ajaxurl="/wp-admin/admin-ajax.php";
   $('#file_upload').uploadifive
  ({
          'auto'             : false,
          'buttonText'       : 'Browse',
          'fileSizeLimit'    : '1024 MB' ,
          'multi'            : false,
          'queueSizeLimit'   : 1,
          'checkScript'      : 'check-exists.php',                
          'queueID'          : 'queue',
          'fileType'     [ 'video/3gpp'],
          'uploadScript'     : 'uploadifive.php',
          'onUploadComplete' : function(file, data) {//window.location =    'upload_to_youtube/processing.php?' + data;
              jQuery.ajax({
                url:ajaxurl,
                data:data+'&action=upload_to_youtube',
                type:'POST',
                success:function(data){

                }
            });


          }

  });

php upload code put this code in function.php file

add_action('wp_ajax_upload_to_youtubee', 'upload_to_youtube_callback');//login user
  add_action('wp_ajax_nopriv_upload_to_youtube', 'upload_to_youtube_callback');//for not login user

    function upload_to_youtube_callback()
    {
        //put your upload code
    die;
    }

Simple way.. yet not recommended...

locate your theme directory.

/wp-content/themes/your-theme/

inside the theme directory put your php file. example: test.php.. in your ajax set the url into something like these..

$.ajax({
   url: '/wp-content/themes/your-theme/test.php'
});

then in the test.php put these lines above.

define('WP_USE_THEMES', false);
require_once('../../../wp-load.php');

so you can still use wordpress functions even without calling the theme..