Hi,
I'm reading a xml file using ajax code then loading it to an array.
<script type="text/javascript">
var mycarousel_itemList = [
{ url: "http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg", title: "Flower0" },
{ url: "http://static.flickr.com/75/199481072_b4a0d09597_s.jpg", title: "Flower1" },
{ url: "http://static.flickr.com/57/199481087_33ae73a8de_s.jpg", title: "Flower2" },
{ url: "http://static.flickr.com/77/199481108_4359e6b971_s.jpg", title: "Flower3" },
{ url: "http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg", title: "Flower4" }
];
jQuery(document).ready(function () {
$.ajax({
type: "GET",
url: "CarouselData.xml",
dataType: "xml",
success: function (xml) {
$(xml).find('Item').each(function () {
var title = $(this).find('title').text();
var url = $(this).find('url').text();
mycarousel_itemList[id].url = iconUrl; mycarousel_itemList[id].title = iconUrl; });
}
});
I have a dummy data in the array and replacing it with my actual data for now. Eventually, I want to have the empty array to start with then add array items inside ajax code.. For now those two lines of code below does not work:
mycarousel_itemList[id].url = iconUrl;
mycarousel_itemList[id].title = iconUrl;
after updating data, if I say "mycarousel_itemList[id].url", it gives me 'undefined' .
any idea..? thanks.