2017-09-20 108 views
0

为什么我无法从此Web服务获得响应?为什么我无法从此Web服务获得响应?

$(document).ready(function() { 
    $.ajax({ 
     url: "https://aip-rest.appspot.com/api/token/12416689" 
    }).then(function(data) { 
     $('.greeting-id').append(data.id); 
     $('.greeting-content').append(data.content); 
    }); 
}); 

我测试了与http://rest-service.guides.spring.io/greeting相同的代码,它的工作。

+0

看来,在HTTPS的响应://aip-rest.appspot.com/api/token/12416689没有“id”或“content”,对吧? – Pang

回答

0

Web服务https://aip-rest.appspot.com/api/token/12416689是给你一个XML响应,所以你必须要指出的Ajax调用...

$.ajax({ 
    type: "GET", 
    url: "https://aip-rest.appspot.com/api/token/12416689", 
    cache: false, 
    dataType: "xml", 
    success: function(xmlData) { 
     // Fetch your $(xmlData) to extract what you need 
    } 
}); 

我希望它能帮助

相关问题