title: JSON to javascript to edit the value of JSON
body: <p>I have a JSON file (.json). </p>
  
  <pre><code>"spinOptionArray" : [
   {"probability":100, "type": "string", "value": "SECTION 1", "resultText": "Please choose an item from Section 1"},
   {"probability":100, "type": "string", "value": "SECTION 2", "resultText": "Please choose an item from Section 2"},
   {"probability":100, "type": "string", "value": "SECTION 3", "resultText": "Please choose an item from Section 3"},
   {"probability":100, "type": "string", "value": "SECTION 4", "resultText": "Please choose an item from Section 4"},
   {"probability":100, "type": "string", "value": "SECTION 5", "resultText": "Please choose an item from Section 5"}, 
   {"probability":100, "type": "string", "value": "SECTION 6", "resultText": "Please choose an item from Section 6"}
  ]
  </code></pre>
  
  <p>How to I store the JSON file as a JS object instead? As I want to change the probability value in the JSON file with every click of the button.</p>
  
  <p>Button html (in a .php file):</p>
  
  <pre><code>&lt;button class="spinBtn" id="spinBtn"&gt;SPIN&lt;/button&gt;
  </code></pre>
  
  <p>anyway, used this function to call the JSON</p>
  
  <pre><code>function loadJSON(callback) {
     var xobj = new XMLHttpRequest();
     xobj.overrideMimeType("application/json");
              xobj.open('GET', './wheel_data.json', true);
          xobj.onreadystatechange = function () {
              if (xobj.readyState == 4 &amp;&amp; xobj.status == "200") {
                  //Call the anonymous function (callback) passing in the response
                  callback(xobj.responseText);
              }
          };
          xobj.send(null);
      }
  </code></pre>