Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 945961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:50:18+00:00 2026-05-15T22:50:18+00:00

I’m a newb in ajax stuff, so this is my first project with jquery

  • 0

I’m a newb in ajax stuff, so this is my first project with jquery load().

I did this step-by-step instruction http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/ and it seems to be so easy. The result: works with Webkit and Gecko, but IE 7 + 8, what a surprise, they load no content. The demo of nettuts do it in IE, so what the hell did I wrong?

The code:

// Check for hash value in URL
var hash = window.location.hash.substr(1);

// load content
var href = $(".mainNav li a").each(function() {
    var href = $(this).attr('href');
    if (hash == href.substr(0,href.length-5)) {
        var toLoad = hash + ".html #content";
        $("#content").load(toLoad)
    }
});

$(".mainNav li a").click(function(){
    var toLoad = $(this).attr('href') + "#ajaxedContent";

    $("#content").fadeOut(300,loadContent, function(){
        dynHeights();                                               
    });

    $("#load").remove();
    $('#logo').append('<div id="load"></div>');
    $("#load").fadeIn(100);

    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);

    function loadContent() {
        $("#content").load(toLoad,'',showNewContent())
    }

    function showNewContent() {
        $("#content").fadeIn(300, function() { 
            dynHeights();
            hideLoader();
        });
    }

    function hideLoader() {
        $("#load").fadeOut(300);
    }

    return false;
});

Note: the dynHeights() helps to change heights of shadow borders and should not be part of the problem

any ideas? would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:50:19+00:00Added an answer on May 15, 2026 at 10:50 pm
    // load content
    var href = $(".mainNav li a").each(function() {
        var href = $(this).attr('href');
        if (hash == href.substr(0,href.length-5)) {
            var toLoad = hash + ".html #content";
            $("#content").load(toLoad)
        }
    });
    

    The above makes no sense. For each “li a” within “.mainNav”, you’re loading some remote site, and placing it in “#content”. If you have 4 anchors within “.mainNav”, you’re making 4 AJAX requests, but only showing the one that finishes last (it isn’t even guaranteed to be the last li… it’s a race condition).

    Maybe you want to do this on a click event (in which case change “each” to “click”, or only want to do this on a particular element; in which case limit it using a selector such as “:first”, “:last” or “:eq”.


    The line var toLoad = hash + ".html #content"; will work, but not using the behaviour you’re expecting.

    Assuming hash is a value such as “http://www.google.co.uk“, you’re ending up with toLoad equaling:

    "http://www.google.co.uk.html #content"
    

    The first part is an invalid URL, which wont ever work. The second is the jQuery selector that the response will be placed within.

    You’re probably after var toLoad = hash + " .html #content" (note the addition of a space), however “#content” should be unique on the page, as ID’s should never be duplicated, so this can be simplified to just:

    var toLoad = hash + " #content";
    

    var toLoad = $(this).attr('href') + "#ajaxedContent"; suffers from the same error as before, and should probably be var toLoad = $(this).attr('href') + " #ajaxedContent";.


        function loadContent() {
            $("#content").load(toLoad,'',showNewContent())
        }
    

    The above will not work as you expect. Your call to load provides 3 arguments:

    1. The variable toLoad
    2. A blank string
    3. The result of showNewContent() (which is undefined), NOT the function showNewContent as you are no doubt expecting.

    It should probably be:

        function loadContent() {
            $("#content").load(toLoad,'',showNewContent)
        }
    

    Fixing this mistakes will hopefully resolve the issues you’re having with IE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.