ContentType控制输出的类型是否区分大小写
例如:
context.Response.ContentType="application/json";
context.Response.ContentType="application/Json";
是否相同呢?
本来运行完全没有问题的代码,前台代码:
$.ajax({type:"post",
url:urlAjax+"?OperationType=add",
data:$(formId).serialize(),
success:function(msg){
varobj=jQuery.parseJSON(msg);
if(obj.IsSuccess==true){
$.messager.alert('提示',obj.Msg,'info',SaveOkCallback);
}
else{
$.messager.alert('提示',obj.Msg);
}
EnableButton(true);
}
});
后台代码:
context.Response.ContentType="application/Json";
当我把后台代码修改成
context.Response.ContentType="application/json";
时,前台直接报错了!!是这一句!!
jQuery.parseJSON(msg)
没有IsSuccess属性!!!
最终查出来的原因竟然是一个大小写的问题导致的!!
看来ContentType是区分大小写的,但我没找到相关资料!!