$( document ).ready(function() {
function doAjax( time_from, time_to ){
var dataRsp;
$.ajax({
url: "/query/"+time_from+"/"+time_to,
type: "GET",
dataType: "json",
success: function(data){ dataRsp = data; },
});
alert(JSON.stringify(dataRsp));
};
doAjax(0,0);
}
The above is my code snippet, I need to store the ajax response datain a global variable dataRsp, but I failed to do this.I am very confuse with the variable scope in JS and jquery.Thank you very much.