I have the following code .
var last_id = '';
$('.products').each(function(){
$.ajax({
type: "POST",
url: "index.php",
data: 'id='+last_id,
success: function(id){
last_id = id;
}
});
});
My problem is that , i want to get the last inserted id from ajax success and pass it to ajax when id call on second time. but now it can't get the last_id and in second time it again send as empty string But when i alert it in ajax success it alert the last id ? How can i achieved it ?