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 7765701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:13:47+00:00 2026-06-01T15:13:47+00:00

I am trying to AJAX some content into the #BlogContainer div and cannot seem

  • 0

I am trying to AJAX some content into the #BlogContainer div and cannot seem to get my click function working properly. It seems to be falling apart in the if statement, but I can’t figure out why. I have tested with alert and the return from the JSON is coming through as it should. The initial load also works fine its just the iterating through the JSON return and returning the url to the load function that doesn’t seem to be working.

The effect that I want to achieve is to load page content (blog entries) into the #BlogContainer div using .load and the URLs from the JSON file which point to the content, iterating to the next with each click on the #Nexus div.

My main question is what is the best method for loading dynamically through a JSON return? I had an each function which did the exact same thing as well (it seemed to return the correct result, but would not actually load the content). I decided to use the for loop instead since what I read indicated it was slightly more efficient, though I doubt it would have much impact in my case.

I am completely new to JS / JQ and previously had everything functioning the way I wanted using JQueryTools, but I thought the best way to learn would be to do it myself (with a little help of course 🙂 ).

HTML

<div id="BlogContainer"></div>
<div id="NexusRef" alt="03151201.htm">'03151201.htm'</div>

JSON

{
    "0": "'03151201.htm'",
    "1": "'01191201.htm'",
    "2": "'00000103.htm'",
    "3": "'00000102.htm'",
    "4": "'00000101.htm'"
}​

Javascript

$(function() {
    $('#Navigation').load('navi.htm');
    $('#BlogContainer').load('03151201.htm');
    $('#TT1').load('ajtt1.htm');
    $('#TT2').load('ajtt2.htm')
});

$(function() {
    $('#Nexus').click(function() {
        $.getJSON("BlogRoll.json", function(data) {
            var i = 0;
            var n = ($('#NexusRef').html());
            var length = data.length;

            for (i = 0; i < length; i++) {
                if (data[i] == n) {
                    $(function() {
                        $('#BlogContainer').load(data[i + 1]);
                    });
                } else {
                    alert(data[i + 1]);
                }
            }
        });
    });
});​
  • 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-06-01T15:13:49+00:00Added an answer on June 1, 2026 at 3:13 pm

    this should do it

    $(function() {
        //assuming you have this JSON to work with:
        var pages = {
            "0": "'03151201.htm'",
            "1": "'01191201.htm'",
            "2": "'00000103.htm'",
            "3": "'00000102.htm'",
            "4": "'00000101.htm'"
        }
    
        //add a click handler to your button
        $('#Nexus').on('click', function() {
    
            //prepare a storage url
            var url;
    
            //pick out first link, copy, and remove it
            //works like Array.shift()
            for (var key in pages) {
                if (pages.hasOwnProperty(key)) {
                    url = pages[key];
                    delete pages[key]
                    break;
                }
            }
    
            //Do a GET to retrieve contents and append to container
            $.get(url, function(contents) {
                var contents = url;
                $('#BlogContainer').append(contents);
            });
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load some ajax content into a table, unfortunately it's only loading
Im trying to write a quick plugin that will load some AJAX content into
I'm trying to load in AJAX content into an empty but the div won't
I am trying to load some content into a page using Ajax. The html
I'm trying to load some content into a table using insertAfter(), but the content
I'm trying to get to the bottom of some oddness between doing AJAX with
I'm delving into some AJAX and I'm trying to utilise jQuery. I have an
I'm trying to use an AJAX request to load some information into a table
I've been trying to add some AJAX/jQuery script to my site so that only
The Problem I am trying to run some ajax on one my pages for

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.