1.contentType和dataType
contentType 主要设置你发送给服务器的数据格式
dataType设置你收到服务器数据的格式(如text,json等),最常用的为json。
2.contentType详解
"application/json; charset=utf-8" 要求data必须是json串
"text/html" 对于html
"text/xml " 对于xml
"application/x-www-form-urlencoded" (默认值)
3.data的参数传递
传递json字符串参数时,contentType选择application/json类型,js对象用JSON.stringify(对象)转换json字符串后传递到服务器,服务器端需要用到@
url: "/Home/PostAlbum", type: "POST", contentType: "application/json", dataType:"json", data: JSON.stringify({ "AlbumName": "shanghai", "Entered": "5/9/2013" }), success: function (result) { alert(result); },