【发布时间】:2014-04-29 00:28:37
【问题描述】:
我正在尝试使用 enyo 框架进行 ajax 调用,但我一头扎进了一个问题。我收到的错误消息是 0。这只是一个 0。我确保我的 json 文件链接是正确的,我构建了这个 jsfiddle 来测试它http://jsfiddle.net/mmahon512/CPU8n/2/ 任何帮助都非常感谢。我的主机是 GoDaddy,我确保将 json 扩展正确添加到我的 Web 配置中。 json 文件的链接是正确的,它返回有效的 json。我使用 jsonlint 检查了它。这是 jsfiddle 上的代码:
enyo.kind({
name: "AjaxSample",
components: [
{ kind: "Button", content: "Fetch Users", ontap: "fetch" },
{ name: "repos", content: "Not loaded...", allowHtml: true }
],
fetch: function() {
var ajax = new enyo.Ajax({
url: "@987654322@"
});
ajax.go();
ajax.response(this, "gotResponse");
ajax.error(this, this.gotError);
},
gotResponse: function(inSender, inResponse) {
var output = "";
for(i = 0; i < inResponse.length; i++) {
output += inResponse[i].Id + "
";
}
output += Date.now();
this.$.repos.setContent(output);
},
gotError: function(inSender, inError) {
alert(inError);
this.$.repos.setContent(inError + " " + Date.now());
}
});
【问题讨论】:
标签: enyo