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

181
Vistas
Ajax get request stays on readystate 1, but when i log the response text in the console it displays it without a problem

I cant display the result in my html because the request stays in state 1 and the response text displays undefined. When I access the url it displays the value I want to show on my html. Why is this happening? I'm using django on server side btw. Kinda new to ajax but I haven't been able to find an answer to this problem on other already solved questions.

Code that executes the request:

const getHighScore = (gameID, levelID) => {
  let ajaxPrueba = $.ajax({
    url: `/get-data/${gameID}/${levelID}`,
    type: 'get',
    success: function(data) {
        return data;
    },
    failure: function(data) { 
        console.log('Got an error dude');
    }
  });

  return ajaxPrueba;
}

The parameters i pass on are 1 for gameID and 1 for levelID The url i'm talking about

Also this is what the console returns:

ajaxPrueba = $.ajax({
    url: `/get-data/1/1`,
    type: 'get',
    success: function(data) {
        return data;…
Object { readyState: 1, getResponseHeader: getResponseHeader(e), getAllResponseHeaders: getAllResponseHeaders(), setRequestHeader: setRequestHeader(e, t), overrideMimeType: overrideMimeType(e), statusCode: statusCode(e), abort: abort(e), state: state(), always: always(), catch: catch(e)
, … }
​
abort: function abort(e)​
always: function always()​
catch: function catch(e)​
done: function add()​
fail: function add()​
getAllResponseHeaders: function getAllResponseHeaders()​
getResponseHeader: function getResponseHeader(e)​
overrideMimeType: function overrideMimeType(e)​
pipe: function pipe()​
progress: function add()​
promise: function promise(e)
​
readyState: 4
​
responseText: "22"
​
setRequestHeader: function setRequestHeader(e, t)​
state: function state()
​
status: 200
​
statusCode: function statusCode(e)
​
statusText: "OK"
​
then: function then(t, n, r)​
<prototype>: Object { … }

ajaxPrueba.readyState
4 
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