jQuery: making JSON objects accessiblee outside AJAX calls
JavaScript
var $data = {};
$.ajax({
type: 'GET',
url: 'http://jsfiddle.net/echo/jsonp/',
dataType: 'jsonp',
data: {
text: 'some text',
par1: 'another text'
},
success: function(data) {
var _data = data;
$.each(_data, function(p, v) {
$data[p] = v;
});
}
});
console.log($data);
/*
Object
_: "1341688097030"
par1: "another text"
text: "some text"
__proto__: Object
*/