Good morning.

Is it possible to use ajax to refresh data in a javascript array? If so, please guide me so I can find out.

I am trying to build a flexible website where the user can move certain elements of the page dynamically, and have the changes reflected to the other users.

So basically instead of forcing the user to post position changes and refreshing the browser, I want the ajax script to automagically post the changes 'under-the-hood', and also fetch the changes that other users have made. Then automatically trigger a javascript to update the browser.

In my html I have a javascript array like this:
data = new array();
data[0] = 43§moveto§5§94;232
data[1] = 23§remove§8

Based on this I know what changes needs to be done, but for it to work I need to get the new data at a given interval. And this is where I need some help from you guys :)

Thanks in advance.

Recommended Answers

All 2 Replies

You can use javascript push method to insert new data into existing js Array like below

var strNum = ["1", "2", "3", "4"];
strNum.push("5");
Member Avatar for diafol

What about using localStorage for all the updates etc and then use an update to server at the end? Obviously not applicable if you want to avoid using an update button.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.