I have a JavaScript file which has a variable as such:
var ads = new Array;
ads[0] = "/images/banners/buttonLO_apr.jpg";
...
How can I provide ads[0] a value from a database or an XML file or any other files?
I cannot make major changes on the JavaScript file.
Here’s what you can do (that I know of):
XML files – if the file has Same Origin of your script, then execute an AJAX call on that resource (you can do that fast and simple with a jQuery.get()), you’ll get a string representation of the XML file which you can then start parsing and do all ya things.
DB – There’s no client-only solution (i.e. using just JS) I know of. You should put some cool Server Side script to accept your jQuery.get() and go and read the DB for ya. That’s easily done with PHP but you’ll need a PHP server to run that (for example wamp)