好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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是区分大小写的,但我没找到相关资料!!

查看更多关于ContentType控制输出的类型是否区分大小写的详细内容...

  阅读:62次