gpt4 book ai didi

javascript - 有没有办法使用prototypejs从文本文件中读取数据?

转载 作者:行者123 更新时间:2023-12-03 12:35:30 25 4
gpt4 key购买 nike

我正在编写一个测试,希望prototypejs从文本文件中读取并存储变量。这可能吗?我做错了什么?

Selenium.prototype.doLoadData = function(dataFile) {

new Ajax.Request('dataFile', {
method:'get',
onSuccess: function(data) {
var lines = data.split("\n");
lines.each(lines, function(i) {
var line = lines[i].split(' = ');
window[line[0]] = line[1];

globalStoredVars[line[0]] = line[1];
});
}
}
);
};

最佳答案

PrototypeJS 将 AJAXTransport 对象传递给成功回调,而不仅仅是数据。试试这个

onSuccess: function(resp){
var data = resp.responseText;
//or if your response contains JSON
//and the Content-Type: application/json header was sent in the response
var data = resp.responseJSON;
}

关于javascript - 有没有办法使用prototypejs从文本文件中读取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23750567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com