Files
roi-theme/wp-content/plugins/thrive-ab-page-testing/assets/js/util.js
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

60 lines
1.7 KiB
JavaScript
Executable File

(function ( $ ) {
module.exports = {
ajax: {
get_url: function ( query_string ) {
var _q = this.url.indexOf( '?' ) !== - 1 ? '&' : '?';
if ( ! query_string || ! query_string.length ) {
return this.url + _q + '_nonce=' + this.nonce;
}
query_string = query_string.replace( /^(\?|&)/, '' );
query_string += '&nonce=' + this.nonce;
return this.url + _q + query_string;
},
data: function ( custom_action, type, extra_data, data_type ) {
return {
url: this.url,
dataType: typeof data_type === 'undefined' ? 'json' : data_type,
type: type || 'get',
data: _.extend( {
action: this.action,
custom: custom_action,
nonce: this.nonce
}, extra_data || {} ),
error: function ( jqXHR, textStatus, errorThrown ) {
if ( typeof jqXHR.tcb_error === 'function' && jqXHR.tcb_error.apply( jqXHR, arguments ) === false ) {
return;
}
TVE_Dash.hideLoader();
if ( jqXHR.responseText ) {
try {
var response = JSON.parse( jqXHR.responseText );
TVE_Dash.err( response.message );
} catch ( e ) {
TVE_Dash.err( jqXHR.responseText );
}
return;
}
if ( ! errorThrown ) {
errorThrown = 'An unexpected error occurred. ' + ( jqXHR.status ? ' (Status code: ' + jqXHR.status + ')' : '' );
} else {
errorThrown = 'Unexpected error: ' + ( jqXHR.status ? jqXHR.status + ': ' : '' ) + errorThrown;
}
// finally just the error text
TVE_Dash.err( errorThrown );
}
}
},
do: function ( action, type, extra_data, data_type ) {
return $.ajax( this.data( action, type, extra_data, data_type ) );
}
}
};
})( jQuery );