Load part page with jQuery & AJAX -
i have list of dynamic links on page , div wish load content 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 loads external content loader.php page using jquery script below #ajaxcontent div.
$(document).ready(function(){ $("a").click(function(){ $.ajax({ url:$(this).attr("href"), success: function(response) { $("#ajaxcontent").html(response); } }); return false; }); }); my question how can load content named div element on loader.php page using modification of script above? reason show content called using ajax in correct context on natural url eg: href="loader.php?id=2 proper non javascript enabled / seo practice believe.
update: there explosion pills ! many thanks.
working code is.
$(".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
you use .load in
$("#ajaxcontent").load($(this).attr("href") + " #named-div"); otherwise, parse response yourself:
$("#ajaxcontent").html($(response).find("#named-div"));
Comments
Post a Comment