Javascript Jquery And Using Eval
i am currenty using jquery plugin to read a data file (data.html) data.html has below format [10,20,30,40,50] my jquery data request and the javascript to return values is below f
Solution 1:
You don't need eval
. Just indicate the proper dataType: 'json'
:
function test() {
return $.ajax({
url: 'data.html',
type: 'get',
dataType: 'json',
async: false,
cache: false
}).responseText;
}
var my = test();
alert(my[0]);
or even better do it asynchronously:
functiontest() {
$.ajax({
url: 'data.html',
type: 'get',
dataType: 'json',
cache: false,
success: function(result) {
alert(result[0]);
}
});
}
test();
Post a Comment for "Javascript Jquery And Using Eval"