I have a list of dynamic links on page A and div where I want to load content from another dynamically generated page B based on PHP variables.
<a href="loader.php?id=1">Link 1</a> <a href="loader.php?id=2">Link 2</a> <a href="loader.php?id=3">Link 3</a>
This script successfully loads external content from the loader.php page using the jQuery script below in the #ajaxContent div.
$(document).ready(function(){ $("a").click(function(){ $.ajax({ url:$(this).attr("href"), success: function(response) { $("#ajaxContent").html(response); } }); return false; }); });
My question is how to load content from a named div element on the loader.php page using the script modification above? The reason for this is to show content called using Ajax in its correct context on a natural URL, for example: href = "loader.php? Id = 2, which is correct but not enabled by JavaScript / SEO practice, I suppose.
Update: Explosive pills are almost there! thank you very much.
Working code.
$(".switchMe li a").click(function(){ $.ajax({ url:$(this).attr("href"), success: function(response) { // $("#ajaxContent").html(response); $("#ajaxContent").html($(response).find("#imageInfo")); } }); return false; });
Thanks jimmy
source share