I am using the following code:
$.ajax( {
url: "http://www.earthquakescanada.nrcan.gc.ca/api/earthquakes/latest/7d.json",
dataType: 'json',
success: successHandler
} );
var successHandler = function ( data ) {
console.log( data );
}
For some reason and only in Safari, the "location" property for the objects returned are stripped out. Can anyone explain why and suggest a solution?
It's not a jQuery or $.ajax problem, but the json resource you are trying to get, has a kind of user agent controller.
Try to open the url in Chrome and then in Safari, you will see two different json files from the same url http://www.earthquakescanada.nrcan.gc.ca/api/earthquakes/latest/7d.json
您还可以尝试使用$.getJSON(...)
而不是$.ajax(...)
,因为那样会使您在data
变量中解析出json对象
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.