這正常工作與XMLjQuery的.find與XML,但不是JSON工作
$(document).ready(function() {
$.ajax({
type: "GET",
url: "http://api.soundcloud.com/users/123/playlists.xml?client_id=ID",
dataType: "xml",
success: parse
});
});
function parse(xml) {
$(xml).find("playlists").each(function(){
//var title = $(this).find('title').text();
$("#catTitle").append($(this).text()+ "<br />");
});
}
但是當我改變這一點,這是行不通的。我在$(json).find("playlists").each(function(){
之後放了一個alert(),它永遠不會被調用。有什麼想法嗎?
$(document).ready(function() {
$.ajax({
type: "GET",
url: "http://api.soundcloud.com/users/123/playlists.json?client_id=ID",
dataType: "json",
success: parse
});
});
function parse(json) {
$(json).find("playlists").each(function(){
//var title = $(this).find('title').text();
$("#catTitle").append($(this).text()+ "<br />");
});
}
無法搜索'json'與jQuery,這是一個JavaScript對象或數組。像使用JavaScript對象或數組一樣使用它。 –
是的,我有一個想法,你爲什麼期望它的工作?它也不適用於XML,它只是發生XML有足夠的類似於HTML的結構來欺騙JQuery – musefan
json沒有格式化爲使用.find()方法使用標記 –