我创建了一个非常昂贵的php类,需要在管理页面上处理大量请求。出于这个原因,我正在尝试使用jquery queing + ajax调用来批处理请求但是整个javascript没有触发,我不明白为什么。我不仅仅是一个PHP专家,还有js或jQuery。
代码:
$(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('Queue done');
}
});
//the next line is repeated a couple hundred times with different values
queue.add('arg1', 'arg2'); queue.add('arg1', 'arg2');
});
此代码位于正文中。
包含的脚本(在头部)是:
我已经使用TamperData FF插件检查过,并且ajax发布到script.php只是没有解雇,我不明白为什么......