0

I am reading a xml file and saving the data in array.But I am not able to use the array values later.I have declared everything as global. When I put an alert(myData[3]); I am getting "undefined".Please help.

Below is my code:

function modify_data(xml)
{
//alert("tyur");
$(xml).find('person').each(function(){
    phone = $(this).find('phone').text();
        email = $(this).find('email').text();
    name = $(this).find('name').text();
    myArray_name[n]= name;
    myData[n]=myArray_name[n];
       alert(myData[n]);
    n=n+1;
           });
alert(data);
alert(myData[3]);

}

Edited by Dani: Fixed formatting

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by hielo
0

Did you remember to initialize n to zero somewhere? Did you remember to use dataType: "xml" in your jQuery ajax options?

0

Did you remember to initialize n to zero somewhere? Did you remember to use dataType: "xml" in your jQuery ajax options?

Thanks,
I forgot to initialize n to zero,now it is working.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.