Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
Ajax 500 error cause investigation method

I want to get the url sent by Ajax in fuctions.php on the site made by Wordpress.   With the current code, the following error is displayed on the console.
I checked it from the network with the verification tool, but the preview is a white background and no response is displayed.
I would like to find out the cause of the error, what should I do?

Error

XMLHttpRequest : 500
textStatus     : error
errorThrown    : undefined

Code
main.js

(function($) {
    var url_category = location.href;
    var ajaxUrl = window.location.protocol + '//' + window.location.host + '/wp-content/themes/example/functions.php';
    $.ajax({
        url: ajaxUrl,
        type: "GET",
        data: { url_category: url_category },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log("Failed!");
            console.log("XMLHttpRequest : " + XMLHttpRequest.status);
            console.log("textStatus     : " + textStatus);
            console.log("errorThrown    : " + errorThrown.message);
        },
        success: function (response) {
            console.log("Success!");
            console.log(url_category);
        }
    });
})(jQuery);

functions.php

add_action('wp_ajax_get_case', 'dk_get_case');
add_action('wp_ajax_nopriv_get_case', 'dk_get_case');
function dk_get_case() {
    $headers['Access-Control-Allow-Origin'] = '*';
    $return = ['status' => false, 'data' => [], 'message' => ''];

    $url = $_POST['url_category'];
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda