I'm using something like this,
jQuery(function($) {
function updateData()
{
var html = $.ajax({
url: 'ajaxMap.php?id='+lastId,
success: function(data) {
alert(data);
}
});
}
setInterval(function(){
updateData()
}, 2000);
});
I expect to get a JavaScript array after querying the PHP file. As shown in the code, 'data' is returned after querying the url (The PHP file simply outputs a JavaScript array). When I use alert(data), it shows me the same array. But I cannot use this as an array. For example, I can't use array functions like .length, etc on this. JavaScript treats this as a simple string. What am I doing wrong here? Let me know if I need to provide more information.