问题描述
我已经接到了悬浮窗上传成功以下响应。
I've got the following response from dropzone successful upload.
在此我要取的responseText
From this I need to fetch the responseText
我想:的console.log(response.xhr.responseText)
这显示完整的响应文本
I tried: console.log(response.xhr.responseText)
this show the full response text.
当我尝试获取 IMG
从responseText的像这样的的console.log(response.xhr.responseText.img)
控制台掷未定义
When i try to fetch img
from responseText like this console.log(response.xhr.responseText.img)
the console throw undefined
推荐答案
在你的样品, rexponse.xhr.responseText
的值是一个字符串,而不是一个对象。您可以分析字符串转换为对象并访问 IMG
属性:
In your sample, the value of rexponse.xhr.responseText
is a string, not an object. You can parse the string into an object and access the img
property:
(JSON.parse(response.xhr.responseText))。IMG
...但是,由于悬浮窗成功
活动获得文件
对象,无论是解析的responseText
,你可以写一个成功
处理程序是这样的:
...but, since Dropzone success
events get both the file
object and the parsed responseText
, you could write a success
handler like this:
new Dropzone("#myUploader", {
url: "/upload",
init: function () {
this.on("success", function (file, responseText) {
console.log(responseText.img);
});
}
});
有关更多信息,请访问常见问题。
for more information, check out the FAQ.
这篇关于从悬浮窗的Ajax响应获取响应文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!