Skip to content

responseType为json,尝试访问responseText,触发异常。 #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/fly.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,14 @@ class Fly {
engine.onload = () => {
try {
// The xhr of IE9 has not response field
let response = engine.response || engine.responseText;
var response;
if (!engine.responseType || engine.responseType === "text") {
response = engine.responseText;
} else if (engine.responseType === "document") {
response = engine.responseXML;
} else {
response = engine.response;
}
if (response && options.parseJson && (engine.getResponseHeader(contentType) || "").indexOf("json") !== -1
// Some third engine implementation may transform the response text to json object automatically,
// so we should test the type of response before transforming it
Expand Down Expand Up @@ -285,7 +292,7 @@ class Fly {
onerror(e)
}
} catch (e) {
onerror(new Err(e.msg, engine.status))
onerror(new Err(e.msg||e.message, engine.status))
}
}

Expand Down