Last active
August 23, 2017 19:25
-
-
Save sixtyfive/19ec4d8f69c824cb0f27eba76e28d782 to your computer and use it in GitHub Desktop.
JS scope question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Taken from https://stackoverflow.com/questions/9838812/how-can-i-open-a-json-file-in-javascript-without-jquery | |
function loadJSON(path, success, error) { | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function() | |
{ | |
if (xhr.readyState === XMLHttpRequest.DONE) { | |
if (xhr.status === 200) { | |
if (success) { | |
success(JSON.parse(xhr.responseText)); | |
} | |
} else { | |
if (error) { | |
error(xhr); | |
} | |
} | |
} | |
}; | |
xhr.open('GET', path, true); | |
xhr.send(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
tinymce.create('tinymce.plugins.InsertExercise', { | |
InsertExercise: function(ed, url) { | |
... | |
function showDialog() { | |
... | |
loadJSON(exercises_url, | |
function(data) { | |
/* I need to access "ed" here! Possible somehow? */ | |
}, | |
function(xhr) {console.error(xhr);} | |
); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment