比如如下jquery的构造
//广播发出按钮ajax传给server
$("#mestoallbutton").click(function(){
$.ajax({
type: "POST",
url:"/ajaxboardcast",
async:false,
dataType:"html",
data:{content:$("#messagetoall").val()},
success: function(msg){
alert(msg);
$("#mestoall").hide();
}
});
});
其中msg是服务器发回的数据,在处理业务逻辑之后发回结果提示,如成功,或失败原因。
这时候可能会得不到字符串的提示,而是[object XMLDocument]
原因是ajax内没有指定数据类型,dataType:"html",指定后成功解析字符串类型。