jeudi 5 février 2015

Scope and $.get [duplicate]



This question already has an answer here:




This is probably a crazy stupid question, but I don't get why the things variable is not being reset. Here's what I have:



var things = "";

jQuery.get("/Users/MyName/Documents/File.txt", function(data) {

things = data;

});

console.log(things)


Whenever I do the console log within the function, it works. When I take it out of the function, it doesn't work. I thought I was setting the things var globally but apparently not?





Aucun commentaire:

Enregistrer un commentaire