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

The Archive Base Latest Questions

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

on $(document).ready(function() in index.php, the below AJAX is executed, running the file getData.php: if

  • 0

on $(document).ready(function() in index.php, the below AJAX is executed, running the file getData.php:

if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("dataSuccess").innerHTML=xmlhttp.responseText;
        } 
      }
    xmlhttp.open("GET","getData.php",true);
    xmlhttp.send();

In the getData.php file, data is gathered from MySQL and put in JS-arrays:

  var guestData = new Array("<? for ($j=0;$j< sizeof($guestData);$j++) { print     ($guestData[$j]); ?>","<?php } $j = $j+1; ?>");

And finally, store the data in my js arrays into LocalStorage:

   var guestDataCols = new Array();
    guestDataCols = guestData[0].split(",")


        var arrayIndex=0;
        for(arrayIndex=0;arrayIndex<guestData.length-1;arrayIndex++)
        {
            localStorage.setItem(arrayIndex, guestData[arrayIndex]); // storing
        }

EVERYTHING works! But the problem is that my AJAX code doesn’t seem to run through the entire getData.php file since LocalStorage in yet empty after the php-file is executed via AJAX. However (and this is a big one), if I simply refresh getData.php in another window, data is stored perfectly and evernything works. I’ve also tried using jQuery for this as suggested in another Stack Overflow question

  $('#dataSuccess').load('getData.php'); //instead for the AJAX code 

but with the exact same and somewhat mediocre result. So my questions is, why isn’t the AJAX script running the entire php file and HENCE, why is no data stored in LocalStorage?

  • 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:20:42+00:00Added an answer on June 1, 2026 at 3:20 pm

    I think you’re looking for jQuery.getScript

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

Sidebar

Related Questions

Jquery Code <script type=text/javascript> $(document).ready(function() { $.getJSON(http://localhost/index.php/upload/history,function(data) { $.each(data.images, function(i,data) { $('#recent').html( '<img src=/t/'
I have been tearing my hair with this one for a while. index.php: $(document).ready(function(){
I have a script, see below: Index page: jQuery script <script type=text/javascript> $(document).ready(function(){ $(#loadmorebutton).click(function
I have a ajax function as below <script type=text/javascript> $(document).ready(function () { var timer,
Why is this not working? $(document).ready(function(){ var content = '<a href=http://example.com/index.php><b>Some text!</b></a> - <a
Please check the below code $(document).ready(function(){ var href; if(href!=null) { setContainerHtml($.cookie(activeElementHref)); }; $('nav ul
$(document).ready(function() { $('#content').html(''); $.ajax({ url:'data.json', dataType: json, success: function(data) { $('#content').append('<p>'+data.rank+'</p>'); } });}); In
I have this code : <script type=text/javascript> $(document).ready(function() { $('a[name=linkArtist]').click(function(e) { e.preventDefault(); $('#changeArtist').val($(this).attr('title')); });
I use those js files below: jquery-1.4.2.min.js include/jcarousel/lib/jquery.jcarousel.min.js include/mousewheel/jquery.mousewheel.js in my index.php file i
The script below works as far as i can tell: <script type=text/javascript language=javascript> $(document).ready(function()

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.