Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

429
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda