我是 json/javascript 的新手,所以请多多包涵。我正在从加载某事的 api url 获取 json 数据
{
"employees": [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
我需要它作为脚本文件上的 javascript 变量
var employess={
"employees": [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
}
试过了
$.getJSON(myUrl",function(data){ $("#selector").data("JSONP",data); alert(data); });