duandaiqin6080 2017-04-03 09:43
浏览 35

ajax触发错误功能甚至响应有效json和状态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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 孪生网络模型,当训练集与测试集共用一个数据集时,训练准确率为100%,而测试准确率仍在50%左右浮动(正常来说测试的都是学习过的数据,准确率应为100%)。【不要GPT及任何大模型回答】
    • ¥15 怎么在c语言上输出对应数据类型的内存大小以及数值范围
    • ¥30 河流的geojson数据为什么放到mapshaper网站中全部是长方形
    • ¥15 谁能介绍一个可以搜索大部分单词的,每个单词有词根词缀记忆方法的电子书和配套软件吗?给你报酬,你可以给电子书和配套软件给我吗?可以的话加我微信:15218392686
    • ¥20 ANSYS fluent烟雾扩散仿真
    • ¥15 新建vitis工程时,显示创建失败,需要查看vitis log
    • ¥15 java 在同一包下无法跨文件引入自己写的类,也无法导包过去
    • ¥15 求帮生成一个lattice diamond的许可证
    • ¥15 大一前端新生求教学解答
    • ¥15 如何制作一个可以查看“网游有序列的装备词条”的软件/插件