I make an ajax call to my server to retrieve some records and return them as a JSON object. Here is the code for the call
$(".reply").click(function (){
$.ajax({
url: "/ajax_up/",
type: 'GET',
dataType: "json",
success: function (data) {
sync_data=JSON.stringify(data)
}
});
Am trying to use the returned data to construct grid, so when I pass the variable syncd_data which I have declared global in the Ajax call, It seems to be undefined.
$(document).ready(function(){
var data = source_data;
//other code
..........................
..........................
But when I do alert(sync_data) from within the ajax call as below:
$(".reply").click(function (){
$.ajax({
url: "/ajax_up/",
type: 'GET',
dataType: "json",
success: function (data) {
sync_data=JSON.stringify(data)
}
});
It shows the data correctly. I can I use this data outside the Ajax call? Any Help Insights or examples will be highly appreciated. Thanks