Reputation: 75
Have a div <div id="test"></div>
.
I load html (test.php?nid=1
) into this div with jquery ajax().
In this loaded html i have another deep link. Example:
<div id="test">
<p>tttttt</p>
<a href="test.php?nid=2">aaa</a>
</div>
How can I load link test.php?nid=2
in same <div id="test">
?
And how load link test.php?nid=3
from test.php?nid=2
in same <div id="test">
?
Whats technigue?
Upvotes: 0
Views: 336
Reputation: 314
When your ajax request to your url succeed, use this to append the loaded data to your div.
$('#test').append(your_data);
Upvotes: 1
Reputation: 79909
I think you will need to make this in a recursive way by binding the click event to the populated anchor and make it call a function like this :
function getLink(id){
$.ajax({
url: "test.php?nid=" + id,
context: document.body,
success: function(){
$('#test').apend("<a id ='" + i + "' >aaa</a>");
$('#test a').live("click", function(event){
event.preventDefault();
getLink($(this).attr('id') + 1);
});
}
});
}
So you first call the function with id =1
like: getLink(1)
, therfore it will append the first a
to the div like <a id="1">aaa</a>
from the url test.php?nid=1
and bind it with click
event that when it will be clicked call getLink(2)
which in turn append the second a with id = 2
from url test.php?nid=2
and when it will be clicked call getLink(3)
and so on...
Upvotes: 0