kylex
kylex

Reputation: 14406

jQuery load a page on click then automatically load a div

I am wanting to redirect a page on click, and then load specified content into on of those pages div.

How do I go about doing this?

For example:

<div id="redirect">Click here to go to new page</div>

When the new page loads, there will be a div with id = content that needs to have content automatically loaded via ajax based on data sent from the redirect id on the previous page.

Upvotes: 0

Views: 6464

Answers (2)

Ionuț G. Stan
Ionuț G. Stan

Reputation: 179109

How about good old HTML?

<div><a href="page.ext?id=1">Click here to go to new page</a></div>

Then, use some server-side technology to render the desired content on page.ext.

Upvotes: 1

Sarfraz
Sarfraz

Reputation: 382676

Something like this:

$(function(){
 $('#redirect').click(function(){
   window.location = 'your_page.php?id=' + id_here;
 });
});

On the next page you can load data anyway you want based on the id query string value.

Upvotes: 2

Related Questions