0

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.

3
Contributors
2
Replies
9
Views
7 Years
Discussion Span
Last Post by diafol
0

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");
1

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.