想了解ContentType控制输出的类型是否区分大小写的相关内容吗,在本文为您仔细讲解ContentType区分大小写的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:ContentType,区分大小写,下面大家一起来学习吧。
例如:
context.Response.ContentType = "application/json";
context.Response.ContentType = "application/Json";
是否相同呢?
本来运行完全没有问题的代码,前台代码:
$.ajax({ type: "post",
url: urlAjax + "?OperationType=add",
data: $(formId).serialize(),
success: function (msg) {
var obj = 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是区分大小写的,但我没找到相关资料!!