【发布时间】:2011-04-14 02:00:35
【问题描述】:
如何确定 Jquery 中 ajax 调用的响应类型?有时,服务器发送 json 响应,有时它只发送 html 用于显示目的。现在我正在使用
if(response.indexOf('Error'))
//popup error message
else
response.username
response.address
【问题讨论】:
-
您是否尝试查看响应的标头 MIME 类型?
-
可以通过
typeof response=="object"查看