I am not getting an array, I am getting ids.js contents
On Sep 22, 8:12 pm, FrenchiINLA <[EMAIL PROTECTED]> wrote: > inside of your success function success: function(data){} you should > refer to 'data' if you're getting back an array, you can refer to as > data[0][0] > > On Sep 21, 9:04 pm, "seo++" <[EMAIL PROTECTED]> wrote: > > > I am trying to insert array elements through ajax request, these > > elements are also arrays or multidimensional arrays. here is an > > example > > > main script : > > var list = []; > > $.ajax({ type: "POST", > > url: 'http://example.com/ids.js', > > data: "id=1" , > > dataType: "script", > > success: function(data){ > > alert( list[1][0] ); > > } > > }); > > > ids.js contents: > > list[1] = [['aaa', 'bbb'], ['ccc', 'ddd']]; > > > that would produce ' list is undefined' error > > but changing datatype to 'html' and adding eval() would work fine > > var list = []; > > $.ajax({ type: "POST", > > url: 'http://example.com/ids.js', > > data: "id=1" , > > dataType: "html", > > success: function(data){ > > eval( data); > > alert( list[1][0] ); > > } > > }); > > > any ideas what am i doing wrong ?