Wordpress error in Jquery no admin-ajax.php [500]

Asked

Viewed 48 times

0

inserir a descrição da imagem aquiI am developing a delivery in Wordpress the add items to the cart was working normal when was no localhost , after climbing the delivery to test it stopped working , I have the following error log on console.

jquery-1.12.4-wp.js?ver=1.12.4-wp:4 POST https://servedelivery.com.br/servedelivery-5.6/wp-admin/admin-ajax.php 500

1 answer

1

From the description, this happened when you changed the project to localhost, AJAX is sending the request to the old site, you need to change ajax action url and point to the new route.

I recommend leaving the dynamic url to avoid problems with migrations, for example:

 * Adiciona um script no footer que vai inserir uma variável js com uma URL
 * que será utilizada para requisições AJAX
 */
function _theme_load_ajax()
{
    $script = '<script>';
    $script .= 'let ajaxUrl = "' . admin_url('admin-ajax.php') . '";';
    $script .= '</script>';

    echo $script;
}
add_action('wp_footer', '_theme_load_ajax');

Call the variable ajaxurl in the ajax route

Browser other questions tagged

You are not signed in. Login or sign up in order to post.