When a certain image is clicked I want to add some content to a different page using jQuery
. I have a generic page called product.php
and on this page the content to be added depends on which image it is clicked on the home page (home.php)
. On product.php
I am trying to add the content on a div with the id of #product
.
But when the image is clicked it redirects to the unmodified page of product.php
. Is there a way to redirect to the product.php
page after the wanted content is loaded?
$('.product img').click(function () {
// it gives the right index
var index = $( ".product img" ).index( this );
// it works well
var myProduct = 'snippet-product'+ (index + 1)+'.php';
$( "#product" ).load( myProduct );
// it redirects to the 'product.php' without the new content
window.location.href = 'product.php';
return false;
});