2019独角兽企业重金招聘Python工程师标准>>>
1、问题描述:在Firefox浏览器调ajax获取json数据时,控制台提示“XML 解析错误:格式不佳”。
返回设置,加个 application/json
[WebMethod]
public void Data_Back(string token, string data)
{
//Context.Response.ContentType = "text/plain";
Context.Response.ContentType = "application/json";
Context.Response.Write(BaseClass.BaseMethod.getData(token, data));
Context.Response.End();
}
vue的http请求,也加了个判断
// 浏览器判断
var Content_type = '';
switch (browserSelect()) {
case 'firefox':
Content_type = 'application/json;';
break;
default:
Content_type = 'application/x-www-form-urlencoded;';
break;
}
//
.........
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': Content_type
}
.........
就好了