Solution:
After checking a lots of stuff I got the solution to upload any file using this code
jQuery(function () {
jQuery('#test_import_url_button').click(function () {
var importdata = new FormData();
var importfile = jQuery('#import_url_data')[0].files[0];
importdata.append('import_file', importfile);
importdata.append('import_file_name', importfile.name);
importdata.append('action', 'wpretarget_import_url');
jQuery.ajax({
url: ajaxurl,
data: importdata,
processData: false,
contentType: false, // this
dataType: 'json',
type: 'POST',
success: function (response) {
alert(response);
}
});
});
});
And this article help me to resolve the error
https://www.sitepoint.com/enabling-ajax-file-uploads-in-your-wordpress-plugin/