0

Currently i have an external json file and i have a function that gets that json and performs a function.

I also have a text area which the user can paste a value.

What i want is that whatever the user pastes into this box is taken and loaded into the same thing that the function i have is loaded.

External json file: file1.json

Looks something like...

{
    "ABCD": {
        "vers": "25a",
        "WWW": "ACD",
        "Actions": {
            "Set": {

            }
        }
    }
}

Javascript file: file2.js

  // load the json  - this loads the external stuff fine//
  //i comment out some parts of this json file and i want the user to now 
  //manually add it in a text area and when they load this page the value of  
  //the text area is added to this 'control' too.

    var a = $.getJSON("media/v01/one.json", function(a) {
        control.load(a);
    });

My text area is inside index.html page under key '1'

the new function i want to add should take this value from the text area and load it into 'control' aswel. control is my own control which has a load method. but when i do control.load() nothing happens.

**maybe there is another method i can use? **maybe there is a javascript way to just add the value of the text area to the 'control'. **or maybe a java script way of adding the value of the text area to my json file and not needing to add any load function?

something like....

    var b = $.getJSON(localStorage.getItem('1'), function(b) {
        control.load(b);
    });

//localStorage.getItem('1') returns json value. //I want this value to be loaded into 'control'

Error: When i load the page its blank. xhr.send( options.hasContent && options.data || null )

Thanks in advance :)

sarah
  • 147
  • 1
  • 3
  • 11
  • Could you expand a bit more on what you mean by "load it the same way"? – derp Nov 16 '16 at 22:24
  • Hello and Thank you for your reply. I have updated my post :) – sarah Nov 16 '16 at 22:32
  • Do you have a web server set up to serve the external JSON file? This answer might provide some insight into how you might do it http://stackoverflow.com/questions/19706046/how-to-read-an-external-local-json-file-in-javascript – derp Nov 16 '16 at 22:49

0 Answers0