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

224
Vistas
ajax get json from web API but return error

I use ajax to get json from a web API as following.

The browser log shows that json result is extracted, but the page returned the error function: alert("Please try later"). browser log image Is there anything wrong?

Thanks!

$.ajax({  
   url :"http://dgidb.genome.wustl.edu/api/v1/interactions.json", 
   type:"get",  
   async:false,  
   data: {genes: genes, interaction_sources: interaction_sources},
   dataType:"jsonp",
   jsonp:"callback",
   jsonpCallback:"message",
   success: function(data){  
      alert(data);
   },
   error: function(){  
      alert("Please try later");
   } 
}); 
about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Remove dataType:"jsonp" or use dataType:"json"

about 4 years ago · Santiago Trujillo Denunciar

0

Using your code I could not get it to work unless I added quotes around the "genes" and "interaction_sources".

If I access the url: http://dgidb.genome.wustl.edu/api/v1/interactions.json directly it says: {"error":"You must enter at least one gene name to search!"}

Perhaps instead of the "genes" and "interaction_sources" you should be using search parameters?

EDIT: if you could provide the API for the json you are trying to access we might be able to debug it?

$("#runme").on("click", function() {
  RunMe();
});

function RunMe() {
  $.ajax({
    url: "http://dgidb.genome.wustl.edu/api/v1/interactions.json",
    type: "get",
    async: false,
    data: {
      genes: "genes",
      interaction_sources: "interaction_sources"
    },
    dataType: "jsonp",
    jsonp: "callback",
    jsonpCallback: "message",
    success: function(data) {
      alert(data);
    },
    error: function() {
      alert("Please try later");
    }
  });

};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

<button id="runme">RUN ME!!!</button>

about 4 years ago · Santiago Trujillo Denunciar

0

Ensure API response date with application/json header

{
  "matchedTerms": [],
  "unmatchedTerms": [
    {
      "searchTerm": "GENES",
      "suggestions": []
    }
  ]
}

This response's Content-Type would be application/json. I tried this is on POSTMAP manually and it worked. Just fixed the Content-Type header value.

about 4 years ago · Santiago Trujillo Denunciar
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