I am writing a Sql convertor which handles mysql to mongodb. I am writing an interface to my converter with ajax.
Ajax is handling huge convertions. This put limit to mysql select code and make convertions parted by 1000 at a time.
my code is :
$(document).ready(function()
{
<!--Start JQuery Ajax Requests-->
var pages;
var type;
$("input").click(function(event) {
pages = $(this).attr("icr");
type = $(this).attr("id");
runRequest(0);
});
function runRequest(num){
if (num > 3){
$("#console").append("Finish!!!");
return;
}
$.ajax
({
type: "POST",
url: "#",
async: false,
data: "type="+type+"&page="+num*1000,
success: function(msg){
$("#console").ajaxComplete(function(event, request, settings)
{
$("#console").append(msg);
runRequest(num+1);
});
}
});
}
});
this code have to run 3 times of the same function and send the limit number by multiplying it. But somehow runRequest's num variable never reaches the 3, firebug console shows num as 1 or sometimes 2 and it repeats infinite. How to avoid it and make it run only 3 syncronised calls?