Thought I’d share something with you guys. I have been building an Ajax website for work using ASP.NET, I hate all the silly controls that come with .NET so I use JS to talk to the VB codebehind pages and then return the response using XMLhttp.ResponseText. This all worked out great until I remembered I had dropdown lists that wouldn’t contain the ‘current’ data from the database after I had inserted/edited some of the data. Obviously I didn’t want to refresh the whole page and I absolutely did not want to use the ASP UpdatePanel so I found an article on how to refresh certain elements of a page using jQuery:
I had to amend their example slightly to accomodate IE7, by sticking a random number on the end of URL when pushing the update. I also use setTimeout (1000 milliseconds) AFTER a button click so it only does the refresh once, and not all the time as setInterval does.
‘updateTheContent’ is the div to be updated, which my dropdownlist is held in.
I assume this can be used for any element with an ID or class. This seems to work for me in all the browsers, I have spend ages finding something like this (that actually works) so hopefully I have saved someone some time!