我可能也没弄清楚,反正有两种方法我用着挺好用的:直接贴代码
(1)
$.ajax
({
cache: false,
async: false,
dataType: 'json', type: 'post',
url: "dbdt/getDBDT",
data:{year:2017},
success: function (data){
map1Layer=data[0].URL;//矢量
map2Layer=data[1].URL;//影像
}
});
(2)
$(document).ready(function(){
$.get("dbdt/getDBDT",
{year:2017},
function(e) {
console.log(e);
map1Layer=e[0].URL;
map2Layer=e[1].URL;
},"json")
})