Ich mag ein JSON-Objekt zu assoziativem Array konvertieren, aber es sieht aus wie ich es nicht in der Lage war zu Recht zu machen:Von JSON-Array in HTML-Tabelle assoziativen
$(document).ready(function() {
$('#button').click(function() {
$.getJSON("http://www.omdbapi.com/?s=apple", function (json) {
console.log(json);
var body = document.body,
tbl = document.createElement('table');
tbl.style.width = '100px';
tbl.style.border = '1px solid black';
for(var i = 0; i < 4; i++){
var tr = tbl.insertRow();
for(var j = 0; j < 4; j++){
var td = tr.insertCell();
td.appendChild(document.createTextNode("mela"));
td.style.border = '1px solid black';
}
}
body.appendChild(tbl);
});
});
});
Ich mag auch, dass die Daten auf ein setzen Tisch, also statt "Apfel" weiß ich nicht, was ich setzen soll. (ich, dass die Anzahl der Zellen und Spalten weiß nicht 4 sein und 4, das ist ein Beispiel) Die json Anfrage in etwa so sein wird:
{"Search":[{"Title":"Titanic","Year":"1997","imdbID":"tt0120338","Type":"movie","Poster":"https://images-na.ssl-images-amazon.com/images/M/MV5BMDdmZGU3NDQt[email protected]._V1_SX300.jpg"},{"Title":"Titanic II","Year":"2010","imdbID":"tt1640571","Type":"movie","Poster":"https://images-na.ssl-images-amazon.com/images/M/[email protected]@._V1_SX300.jpg"},{"Title":"Titanic: The Legend Goes On...","Year":"2000","imdbID":"tt0330994","Type":"movie","Poster":"https://images-na.ssl-images-amazon.com/images/M/[email protected]@._V1_SX300.jpg"},{"Title":"Titanic","Year":"1953","imdbID":"tt0046435","Type":"movie","Poster":"https://images-na.ssl-images-amazon.com/images/M/[email protected]_V1_SX300.jpg"},{"Title":"Titanic","Year":"1996","imdbID":"tt0115392","Type":"series","Poster":"https://images-na.ssl-images-amazon.com/images/M/[email protected]@._V1_SX300.jpg"},{"Title":"Raise the Titanic","Year":"1980","imdbID":"tt0081400","Type":"movie","Poster":"https://images-na.ssl-images-amazon.com/images/M/MV5BM2MyZWYzOTQtMTYzNC00OWIyLWE2NWItMzMwODA0O[email protected]_V1_SX300.jpg"},{"Title":"The Legend of the Titanic","Year":"1999","imdbID":"tt1623780","Type":"movie","Poster":"https://images-na.ssl-images-amazon.com/images/M/[email protected]_V1_SX300.jpg"},{"Title":"Titanic","Year":"2012","imdbID":"tt1869152","Type":"series","Poster":"https://images-na.ssl-images-amazon.com/images/M/[email protected]@._V1_SX300.jpg"},{"Title":"Titanic: Blood and Steel","Year":"2012–","imdbID":"tt1695366","Type":"series","Poster":"N/A"},{"Title":"In Search of the Titanic","Year":"2004","imdbID":"tt1719665","Type":"movie","Poster":"https://images-na.ssl-images-amazon.com/images/M/MV5BMTAzNjY0NDA2NzdeQTJeQWpwZ15BbWU4MDIwMzc1MzEx._V1_SX300.jpg"}],"totalResults":"187","Response":"True"}
Es tut mir leid für die nicht so klar zu sein, ich hoffe jemand wird mir bald helfen.
einen Blick auf die Benutzer-Code haben, bevor er antwortete ... geht $ .getJSON eine js obj ... –