SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I use Jquery to refresh A div from within the already refreshed DIV?

    Here is my code.. for the most part

    <script type="text/javascript">
    $(function() {
    $('#blogform').ajaxForm( {
    cache: false,
    success: function(data) {
    $("#blogentry_body").val("");
    $('#ReloadThis').fadeOut('slow').load('something.php').fadeIn("slow");
    return false;
    }
    });
    });
    $(function() {
    $("#refresh").click(function() {
    cache: false,
    $('#ReloadThis').fadeOut('slow').load('something.php').fadeIn("slow");
    return false;
    });
    });
    </script?

    [form that posts and then refreshes the div]
    [refresh div link]
    <div id="ReloadThis" style='width:715px;overflow:hidden;'>
    somestuff
    blah blah blah
    [link][link2][link3]
    </div>

    those 3 links submits something that changes the content of the div, I want them to submit in the background and then the div refresh just like it does by submiting the form or clicking the refresh div link. I've tried everything I can think of, but the div content does not recognize the javascript so idk...

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by lancxeon View Post
    those 3 links submits something that changes the content of the div, I want them to submit in the background and then the div refresh just like it does by submiting the form or clicking the refresh div link. I've tried everything I can think of, but the div content does not recognize the javascript so idk...
    Use the live event instead, so that jQuery knows that it has to continue to monitor those areas when it updates the content.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much, that works.
    Now i have this

    <a href="blah.php?something=asdf&somethingelse=2" id="refresh">Link</a>

    it does the refresh when I click it, but it does not submit the link in the background.. and although I know for the most part why.. I'm coming up with a blank in my mind, I know PHP in and out, and was learning "older" JS awhile back.. but I have not even started to get the hang of jquery :\

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by lancxeon View Post
    it does the refresh when I click it, but it does not submit the link in the background
    How is the link supposed to be submitted in the background, and do you have a test page so that we can see what's happening in a better context?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •