How to load two divs into separate targets with JQuery?

Posted by Bussard on Stack Overflow See other posts from Stack Overflow or by Bussard
Published on 2010-03-15T20:30:52Z Indexed on 2010/03/15 20:39 UTC
Read the original article Hit count: 200

Filed under:
|

Hi all,

I'm trying to achieve two things, both of which I fail to get at. On a server are a series of notes; all contain a div (id=ajxContent). Some notes also contain an additiona div (id=ajxHead). The ajxContent itself contains links (class=clicking) to call the next installment, hence the link destination in a variable.

This is my code:

$(document).ready(function(){
$( 'a.clicking' ).live('click', function(e){
    e.preventDefault();
    var theLink = $(this).attr('href');
    $('#loadText').load(theLink + '#ajxContent');
    $('h1').load(theLink + '#ajxHead');
});
})

Where it fails:

1) the ajxContent gets loaded into the h1 tag as well as in its intended target. 2) when I had set up the code differently, if there was no div id=ajxHead present in a note, the load would nevertheless erase the existing value in the h1 tag.

Am I on a totally wrong track here, with two load statements? Input is very welcome, thanks.

© Stack Overflow or respective owner

Related posts about beginner

Related posts about jquery-ajax