2016-11-27 69 views
0

我正在嘗試使用jquery ajax進行Zomato API調用,但它們提供了一個curl命令。

curl -X GET --header "Accept: application/json" --header "user-key: key" "https://developers.zomato.com/api/v2.1/cities" 

如何將其轉換爲$ .ajax()調用?

回答

0
$.ajax({ 
    dataType: 'json', 
    url: 'https://developers.zomato.com/api/v2.1/cities', 
    headers: { 
    'user-key': 'put your key in here' 
    } 
    success: function(response, status, xhr) { 
    // Handle the response here. 
    } 
}); 

有關更多信息,請參閱JQuery API docs