Это что-то новое для меня, поэтому, пожалуйста, будьте терпеливы.JQuery & json - я использую json & serialize для "возрастов" в php, но только попал в JQ.Я хочу передать данные между доменами, поэтому массив json кажется мне лучшим, но как его отобразить, например,
скажем, у меня есть такой массив json, созданный в php на имени страницы examplearray.php, расположенном в http://domain1.com/examplearray.php
$catarray = array('Animal Life','Business & Finance','Cars & Vehicles','Entertainment & Arts','Food & Cooking','Health','History, Politics & Society','Hobbies & Collectibles','Home & Garden','Humor & Amusement','Jobs & Education','Law & Legal Issues','Literature & Language','Relationships','Religion & Spirituality','Science','Shopping','Sports','Technology','Travel & Places');
$callback = json_encode($catarray);
Я понимаю, что могу назвать это так из другого домена, скажем http://domain2.com
$(document).ready(function(){
$.getJSON("http://domain1.com/examplearray.php?callback=",
function(data){
$.each(data, function(i,item)
{
// WHAT DO I put in here to read the array? i.e. what are the keys etc. //
// I assume the display is something like $('#element').html('something');
});
});
});
В приведенном выше примере нет никаких "установленных" ключей, если вы следуете этому, ноТеперь добавьте ключ к массиву, как этот
$catarray = array('keyname' => array('Animal Life','Business & Finance','Cars & Vehicles','Entertainment & Arts','Food & Cooking','Health','History, Politics & Society','Hobbies & Collectibles','Home & Garden','Humor & Amusement','Jobs & Education','Law & Legal Issues','Literature & Language','Relationships','Religion & Spirituality','Science','Shopping','Sports','Technology','Travel & Places'));
Помощь очень ценится, спасибо.