I have created a php class which is pretty expensive and needs to process a lot of request on an admin page. For this reason I'm trying to using jquery queing + ajax calls to batch process the requests however the whole javascript is not firing and I don't understand why. I'm more of a PHP expert nog so much js or jQuery.
The code:
<script type="text/javascript">
$(document).ready(function () {
window.queue = $.jqmq({
// Queue items will be processed every 250 milliseconds.
delay: 500,
// Process queue items one-at-a-time.
batch: 10,
// For each queue item, execute this function.
callback: function (model, apit) {
$.ajax({
url: 'script.php',
type: "post",
cache: false,
data: "model=" + model + "&api=" + apit,
success: function (data) {
$(".error_msg p").append(data);
}
},
// When the queue completes naturally, execute this function.
complete: function () {
$.ajax({
url: 'script.php',
type: "post",
cache: false,
data: "cleanup=1",
success: function (data) {
$(".error_msg p").append(data);
}
$('.error_msg p').append('<br /><span class="done">Queue done<\/span>');
}
});
//the next line is repeated a couple hundred times with different values
queue.add('arg1', 'arg2'); queue.add('arg1', 'arg2');
});
</script>
This code is located in the body. Scripts included (in the head) are:
<script type="text/javascript" src="js/jquery-1.4.1.js"></script>
<script type="text/javascript" src="js/jquery.ba-jqmq.js"></script>
I've checked with TamperData FF plugin and the ajax posts to script.php are just not firing and I have no idea why..