我已经开始学习javascript,我在下面写了一段代码。
var dataFetch = $.getJSON("http://localhost:12345/stream", function (Data) {
alert(Data);
$.each( Data, function () {
alert(this);
$("<li>").html(this.rss).prependTo(tweetList);
});
});
dataFetch.done(function () {
alert("done");
});
dataFetch.fail(function () {
alert("fail");
});
当我将链接http://localhost:12345/stream
放入浏览器时,我得到:
{"rss":{"version":"2.0","channel":{"title":"Dave Winer","link":"http://scripting.com/","description":"Dave Winer's \"Scripting News\" weblog, started in April 1997, bootstrapped the blogging revolution.","language":"en-us","copyright":"Copyright 2012 Scripting News, Inc.","pubDate":"Mon, 08 Oct 2012 04:00:00 GMT","lastBuildDate":"Mon, 08 Oct 2012 18:12:27....
........... much more here
但是当我运行这个 html 文件时,我得到了失败的警告对话框 fail。
我通过JSON.stringify(some_json_object).
node.js 服务器代码在本地主机上发送数据。
错误是什么?