I created a array outside the loop and added its value inside the loop, than i cant print use it outside the loop. here is my code , help me .
$(document).ready(function() {
var usr_id = $("#user_id").val();
var tabs_name = new Array("full_body", "hand_uper_limb", "lower_trunk" , "spine" , "upper_trunk") ;
var tab_order = new Array();
$.each(tabs_name , function(value) {
$.ajax({
method: "POST",
url: "kv_load.php",
data: { id: usr_id, tbl_name : 'kv_'+tabs_name[value]},
success: function(response) {
if(response == null || response =="" ) { } else {
var obj = jQuery.parseJSON(response);
ax = jQuery.parseJSON(obj.x_coordinate);
if (ax!==null && ax.length!== 0) {
var len_x =ax.length;
} else {
len_x = 0 ;
}
tab_order.push({ table: tabs_name[value], size: len_x });
}
},
failure: function() {
alert('failed to save your datas. ');
}
});
});
$.each(tab_order, function (index, value) {
alert( value.table + ' : ' + value.size );
});
});
Here "tab_order" is my array variable, i declared it from the beginning of dom ready, And add items inside the each function, after that i come out to print the array, But it results empty. If you are not clear ,tell me I will explain in detail.
Thanks for all of your answers, Finally my problem is resolved here. with below answers,
