(function () {
var id="test";
$.ajax({
context: this,
url : "http://weather.yahooapis.com/forecastrss",
success : function(data){
this.id = "was test";
}
});
console.log(id);
})();
The previous question wasn't clear enough so hear is what the question really is. When I'm doing console.log(id)
it doesn't show the changed value. What I'd like to get is the changed value of id
. How can I achieve this, I've tried all the solutions in the comments and the given answers as well but none has worked for me?
A jsFiddle will be highly appreciated.