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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:32:45+00:00 2026-05-29T10:32:45+00:00

I am trying to loading sites from a JSON array to divs one by

  • 0

I am trying to loading sites from a JSON array to divs one by one. (once loading has finished, then loading the next one), but I do not know how to set it by myself? Sorry for jsfiddle.net
not allowed by Access-Control-Allow-Origin.

$(document).ready(function() {
//var mark = false;
//if(mark==false){
    //var json = {"set":"[{'web':'google','site':'http://www.google.com'},{'web':'bing','site':'http://www.bing.com'},{'web':'yahoo','site':'http://www.yahoo.com'}]"} 
    var json = {"set":"[{'web':'google','site':'1.html'},{'web':'bing','site':'2.html'},{'web':'yahoo','site':'3.html'}]"} 

    json = eval(json.set);
    for(var i=0; i<json.length; i++){
        var divid = json[i].web;
        var url = json[i].site;
        $('#'+divid+'').load(''+url+'',function(){
            //mark = false;
        });
    }
//}
});



<div id="google"></div>

<div id="bing"></div>

<div id="yahoo"></div>​
  • 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-29T10:32:46+00:00Added an answer on May 29, 2026 at 10:32 am

    Sorry for jsfiddle.net not allowed by Access-Control-Allow-Origin.

    Your problem has nothing to do with jsfiddle. Due to same origin policy restrictions that’s built in browsers you simply cannot send AJAX requests cross domain. You can forget about doing:

    $('#google').load('http://www.google.com');
    

    unless of course the page containing this script is hosted on http://www.google.com.

    In your case you could build a server side script on your domain (using some server side language such as PHP, Java Servlets, ASP.NET, …) that will serve as a bridge between your domain and the remote domain that you are trying to fetch. Then you will send your AJAX request to your server side script.

    You may also take a look at the following article which explains some cross domain AJAX techniques.


    UPDATE:

    Assuming you want to queue your AJAX requests in such a way that the second request is triggered only after the first succeeds and so on you could write a recursive method:

    $(function() {
        // TODO: it's pretty trivial to build this list array given your initial
        // json object, so I am not including it here
        var list = [
            { url: '/url1/', target: '#google' },
            { url: '/url2/', target: '#bing' },
            { url: '/url3/', target: '#yahoo' },
        ];
    
        (function(list) {
            var element = list.shift();
            if (element) {
                var caller = arguments.callee.caller;
                $(element.target).load(element.url, function() {
                    caller(list);
                });
            }
        })(list);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im loading an image from a SQL CE db and then trying to load
I'm trying to embed a flash file from my site, but for some reason
I'm trying to optimize the loading time of a site that has a lot
I'm trying to load profile images (friend images) from Facebook with AS3 but I
I'm trying to display a loading icon while my iPhone app downloads a network
I'm trying to display an update progress loading image whenever my update panel does
I am trying to stop the loading of images with javascript on dom ready
I am trying to make saving and loading easier for some GUIs that I've
I'm trying to get my hovermenuextenders to do some lazy loading. I have avatars
I'm trying to optimize the startup time/class loading time of my Java web app

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.