Error' ) ) { window.bt_import_step_attempt++; $( '.bt_import_report' ).html( $( '.bt_import_report' ).html() + response ); $( '.bt_import_progress' ).hide(); //window.bt_import_ajax( data ); } else { try { var json = JSON.parse( response ); $( '.bt_import_progress span' ).html( json.progress ); window.bt_import_reader_index = json.reader_index; window.bt_import_step++; window.bt_import_step_attempt = 1; data = { 'action': 'bt_import_ajax', 'file': window.bt_import_file, 'step': window.bt_import_step, 'disable_image_processing': window.bt_import_disable_image_processing, 'reader_index': json.reader_index, 'force_download': window.force_download, '_ajax_nonce': window.bt_import_ajax_nonce } window.bt_import_ajax( data ); } catch( err ) { $( '.bt_import_report' ).html( $( '.bt_import_report' ).html() + err.message + ' ' + response ); $( '.bt_import_progress' ).hide(); } } }, error: function( xhr, status, error ) { //console.log( status + ' ' + error ); window.bt_import_step_attempt++; //$( '.bt_import_report' ).html( $( '.bt_import_report' ).html() + '' + status + ' ' + error + '' + '' ); if ( xhr.status == 404 || bt_import_step_attempt > 2 ) { window.bt_import_step++; window.bt_import_reader_index++; window.bt_import_step_attempt = 1; data = { 'action': 'bt_import_ajax', 'file': window.bt_import_file, 'step': window.bt_import_step, 'disable_image_processing': window.bt_import_disable_image_processing, 'reader_index': window.bt_import_reader_index, 'force_download': window.force_download, '_ajax_nonce': window.bt_import_ajax_nonce } } window.bt_import_ajax( data ); } }); } }); })( jQuery ); String.prototype.endsWith = function(suffix) { return this.match(suffix+"$") == suffix; }; if (!String.prototype.startsWith) { String.prototype.startsWith = function(searchString, position) { position = position || 0; return this.indexOf(searchString, position) === position; }; }