深圳 网站建设 销售,中陕核建设集团网站,wordpress网站做app,互联网公司排名2018ajax中response与responseText的区别 1.response与responseText的区别 1.response与responseText的区别
1.1、responseType属性#xff1a;在客户端通过代码告诉请求代理对象#xff0c;服务端响应给我们的数据类型。 MDN链接: responseType的值可参考该处
1.2、下面举个例… ajax中response与responseText的区别 1.response与responseText的区别 1.response与responseText的区别
1.1、responseType属性在客户端通过代码告诉请求代理对象服务端响应给我们的数据类型。 MDN链接: responseType的值可参考该处
1.2、下面举个例子 var xhr new XMLHttpRequest();xhr.open(GET, 15test.php);xhr.send();// 我们通过代码告诉请求代理对象服务端响应给我们的是 JSONxhr.responseType json;xhr.onreadystatechange function () {if (this.readyState ! 4) return;console.log(this.response);// this.response 获取到的结果会根据 this.responseType 的变化而变// this.responseText 永远获取的是字符串形式的响应体//注意在客户端这样设置responseType会有兼容问题所以一般不这样写};