From 263f6b5dea61f082ca34f5ba4d3c4b77603ea462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Fri, 24 Aug 2018 18:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9request=E6=A8=A1=E5=9D=97,?= =?UTF-8?q?=E5=8F=AA=E8=A6=81=E6=98=AFajax,=20=E9=83=BD=E5=8A=A0=E4=B8=8Ax?= =?UTF-8?q?-requested-with=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/request/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/request/index.js b/src/request/index.js index d841be8..a9754f6 100644 --- a/src/request/index.js +++ b/src/request/index.js @@ -438,10 +438,11 @@ class _Request { } } - // 2.3 如果不是跨域请求,则自动加上一条header信息,用以标识这是ajax请求 - if (!this.opt.crossDomain) { + // 2.3 如果不是JSONP,则自动加上一条header信息,用以标识这是ajax请求 + if (this.opt.method !== 'JSONP') { this.set('X-Requested-With', 'XMLHttpRequest') - } else { + } + if (this.opt.crossDomain) { supportCors && (this.xhr.withCredentials = true) }