在Javascript中从外部源导入JSON提要

Dan*_*ber 0 javascript jquery json curl file-get-contents

我想使用Javascript从外部源加载JSON提要; 什么是最好的方法?我已经在PHP中工作了很多,使用file_get_contents或cURL很容易.Javascript中是否有相关的功能或过程?

tbe*_*eda 5

获取一些JSON数据的jQuery可能如下所示:

$.getJSON("http://pathtodata.js", function(json){
  alert(json.dot.notation);
});
Run Code Online (Sandbox Code Playgroud)

指定源以及回调函数.阅读jQuery JSON文档:http: //api.jquery.com/jQuery.getJSON/