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

434
Vistas
ajax firing error function even the response is valid json and status 200

I am using windows server 2012 and i built web app it was working fine on my local PC

but when I uploaded the code to sever the JQuery ajax function firing error function?

I did search around to find out what is the problem but no thing help

I added dataType:"text" and it fire the success function but it does not deal with the returned data as JSON. while when I added dataType:"json" it kept firing the error function

    $.ajax({
    url:url,
    type:"POST",
    data:{collegeID: ID},

    success:function(res){
     if(res.success == 1){
       trigger.append("<OPTION value=''>--Select Teacher--</OPTION>");
       $.each(res.data,function(){
        trigger.append(
            "<OPTION VALUE='"+this.teacher_id+"'>"+this.teacher_name_e+" | "+this.teacher_name_a+"</OPTION>"
        );
       });
     }else{
       trigger.append("<OPTION></OPTION>");
     }
     console.log(res);
    },
    error:function(e){
     trigger.append("<OPTION></OPTION>");
     console.log(e);
    }
});

response without adding dataType or with add dataType:"json"

enter image description here

response when I add dataType:"text"

enter image description here

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