I am currently using a jquery plugin to read a data file (data.html)
data.html has the format below
[10,20,30,40,50]
my jquery data request and javascript return values below
function test(){
var result=$.ajax({
url:'data.html',
type:'get',
dataType:'text',
async:false,
cache:false
}).responseText
return result;};
var my=test();
alert(my[0])
I want to get these values in an array format. ie I want my [0] to be a value of 10, but instead I get "[". If I use the eval function
my=eval(test());
I can get 10, but is there any other better way to save the returned ajax calls to an array instead of a string?
thank
, , myArray null ( firebug), async: false, . async: false ? (Http://stackoverflow.com/questions/133310/how-can-i-get-jquery-to-perform-a-synchronous-rather-than-asynchronous-ajax-req)
jQuery.extend({getValues: function(url) {
var result = null;
$.ajax({
url: url,
type: 'get',
dataType: 'json',
cache: false,
success: function(data) {result = data;}
});
return result;}});
myArray=$.getValues("data.html");
alert(myArray[1]);