User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 373,480 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,949 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

returning array from ajax.responseText?

Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation: MattEvans will become famous soon enough MattEvans will become famous soon enough 
Rep Power: 5
Solved Threads: 46
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is online now Online
Posting Shark

Re: returning array from ajax.responseText?

  #4  
Nov 29th, 2007
Yes, that would work. You could also print output like this from PHP:
new Array( "Saab", "Volvo", "BMW" )
and then in javascript:
var myArray = eval( xmlHttp.responseText );
The eval function will treat the plaintext as javascript; returning an array type object in this case. That'd work for a numerically indexed array, you're using string indicies but you can use the same principle,

Don't use this principle the other way round whatever you do; that is, don't send textcode from client to server and evaluate it. That's the biggest security hole you could possibly make.
Last edited by MattEvans : Nov 29th, 2007 at 4:16 am.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
All times are GMT -4. The time now is 5:42 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC