0
我正在localhost:8080
上运行开发服务器,现在正在使用终端。我安装nodejs
用下面的命令:使用来自nodeJS解释器的jQuery ajax
$ brew install node
$ brew install jquery
现在我运行node
解释:
$ node
> var $ = require("jquery");
我定义的函数打印出来不管它获得控制台:
function getSomething() {
$.get("http://localhost:8080",
function(response) {
console.log(response);
});
}
所以在翻译:
> getSomething()
undefined <-- this is what I get
我认为这是由于相同的原产地政策。我如何解决这个问题?我试图练习我的JavaScript,我想在终端而不是浏览器控制台上工作,以保持它的速度。