有人可以帮我用 jquery 接收这个 json 吗?
{
"output_type":"json","diagnostic":{"status":"200","elapsetime":"0.4187","memoryusage":"17.91MB","confirm":"success","lang":"id","currency":"IDR"},"results":{"result":[{"id":"business:3772","label":"Puri Maharani Boutique Hotel & Spa - Denpasar, Denpasar Timur, Kesiman Kertalangu","value":"Puri Maharani Boutique Hotel & Spa","category":"Hotel"},{"id":"business:3852","label":"Maharani Hotel - Jakarta Selatan","value":"Maharani Hotel ","category":"Hotel"},{"id":"business:3874","label":"Maharadja Hotel - Jakarta Selatan, Mampang Prapatan, Tegal Parang","value":"Maharadja Hotel","category":"Hotel"},{"id":"business:4776","label":"Pita Maha Resort and Spa - Gianyar, Ubud, Ubud","value":"Pita Maha Resort and Spa","category":"Hotel"},{"id":"business:4779","label":"The Royal Pita Maha Resort and Spa - Gianyar, Ubud, Kedewatan","value":"The Royal Pita Maha Resort and Spa","category":"Hotel"},{"id":"business:18420","label":"Villa Mahapala Bali - Denpasar, Denpasar Selatan, Sanur","value":"Villa Mahapala Bali","category":"Hotel"},{"id":"business:105246","label":"Mahagiri Dreamland Villas & Spa - Badung, Kuta Selatan, Pecatu","value":"Mahagiri Dreamland Villas & Spa","category":"Hotel"}]},"token":"bc8d3a106572e4cff038261afb568ecf"}
我使用 $.getJSON 和 $.ajax 函数,但出现了一些问题,有人可以帮我处理一些 jquery 代码吗?
这是我的代码,
function getAPI() {
jQuery.ajax({
url: 'http://api.master18.tiket.com/search/autocomplete/hotel?q=mah&token=90d2fad44172390b11527557e6250e50&secretkey=83e2f0484edbd2ad6fc9888c1e30ea44&output=json',
beforeSend: function(x) {
if(x && x.overrideMimeType) {
x.overrideMimeType("application/j-son;charset=UTF-8");
}
},
type:"get",
dataType: 'json',
crossDomain: true,
success: function(data) { console.log(data); }
});
}
但错误是 Uncaught SyntaxError: Unexpected token :