ajax xml not loading initially online
Hello. I'm attempting to load data from an external xml file. This is my code that runs at the beginning.
- /////////////////////////////////
- ////Retrieve level information///
- /////////////////////////////////
- $.get('scripts/level.data.xml', function (d) {
- $(d).find('Level').each(function () {
- var $level = $(this);
- if ($level.attr("Level_Number") == level) {
- var count = 1;
- //Cycle through die contents of level
- $level.find('Die').each(function () {
- $die = $(this);
- $(".dice").append("<button id = 'die" + count + "' class='die' data-role='button' data-inline='true' data-theme='b'>0</button>");
- if (count == 1)
- die1Max = $die.text();
- if (count == 2)
- die2Max = $die.text();
- if (count == 3)
- die3Max = $die.text();
- if (count == 4)
- die4Max = $die.text();
- count++;
- });
- //Cycle through Operators available
- $level.find('Operator').each(function () {
- $operator = $(this);
- $(".operator").append("<button class='operators' data-role='button' data-theme='b'>" + $operator.text() + "</button>");
- });
- boardNumbers = $level.find('Board_Numbers').text();
- }
- });
- });
- ///////////////////////////////////////
This loads on the page load when I run off of my computer. After I upload the game to the server, it retrieves the correct number of elements, but none of the data. I get the same results offline if the code is inserted in the $(document).ready function.
You can view the online version
here.
Notice that after you click on the buttons, the formatting refreshes. Also, after the first equation is completed, the numbers update correctly.