The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript run scripts in a page loaded by ajax

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #40044

    The fact that all script code is being removed when you use jquery.load is really annoying. I am trying to use AJAX so I do not need to reload the entire page.

    Script, currently:

    $(document).ready(function() {

    var hash = window.location.hash.substr(1);
    var href = $(‘#nav li a, #nav-top li a, #nav-left li a, #nav-right li a’).not(‘.scroll’).each(function(){
    var href = $(this).attr(‘href’);
    var toLoad = hash+’.php #content’;

    $(‘#nav li a, #nav-top li a, #nav-left li a, #nav-right li a’).not(‘.scroll’).click(function(){

    var toLoad = $(this).attr(‘href’)+’ #content>*’; // there must be a blank space in ‘ #content>*’
    window.location.hash = $(this).attr(‘href’).substr(0,$(this).attr(‘href’).length-4);
    function loadContent() {
    function showNewContent() {
    function hideLoader() {

    return false;


    Working demo example page here: (Just click the ‘home’ and ‘about’ links to see it in action.)

    I have all of my jquery in three files that are minified; they include things like php/jquery shopping cart, lazyload, lightbox, and more. I’d like all three of my main js files to “stay alive” so that, when I add, for example, an ‘add to cart’ button or img.lazyload to the #content div, those things will still function.

    I’ve heard that the livequery plugin is a decent solution, but it’s way over my head, and to me it seems like possible overkill.

    There must be a way to modify the above script to include one.min.js two.min.js and three.min.js and thus “retrigger” them so they stay active.

    If this question is a big deal I’m willing to hire whoever can figure this out. I can then re-post the solutions here. (This question I’m asking has been asked all over the place, including the main nettuts page where I got the above “load in and animate content using jquery” script, and the solution still evades most people, although some have managed to fix this, I can’t figure out how to implement their solutions. Whoever can resolve this once and for all will be helping hundreds of frustrated people in one shot. You build a whole new site using a nettuts tutorial, only to find out a week into the job that it’s no good for loading content that has associated scripts… it’s damn frustrating.)


    You’ll just have to grab whatever functions you need and run them on your new content.


    I’ve tried about 40 different things; if someone here is interested in a little freelancing let me know.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.