Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

436
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!