Can we update a javascript array variable, with out reloading a page as well as with out refreshing?
I am having a list of data in an array. Later I am getting some more data using php and ajax.
Now I would like to append the new data got from php ajax to the old javascript variable which is already having an array in it. I do not want to reload the page. But we can overwrite the data too.
Using this javascript variable some javascript functions are getting exicuted and displayes some picture according to the data. Can we do something like that? or do we have to reload the frame to execute the javascript?
Can we update a javascript array variable, with out reloading a page as well
Share
Short answer: Yes, you can add/append/concatenate/whatever new array items to an existing array.
Explanation: Assuming that you have a variable containing an array, and a response that is an array or contains an array, you can use the
array.concat()method to append the new content to the old array.