Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Partial page refreshes using jQuery

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #25888
    levis
    Participant

    Hi there,

    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:

    http://blog.mediasoft.be/partial-page-r … nd-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.

    $(‘#cidAmendBtn’).click(function() {
    var url = "http:www.your-url.com?ID=" + Math.random();
    setTimeout(function() {
    $("#updateTheContent").load(url+" #updateTheContent>*","");
    }, 1000);
    });

    ‘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!

    Cheers

    #62796
    Rob MacKay
    Participant

    awesome – thanks for sharing :D

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Other’ is closed to new topics and replies.