【发布时间】:2014-05-29 12:50:44
【问题描述】:
我正在尝试获取以下代码以通过 POST 将变量发送到 PHP 页面。我不太确定该怎么做。这是我通过 GET 发送数据并通过 JSON 编码接收数据的代码。我需要更改什么才能通过 POST 将变量传递给 process_parts.php?
function imagething(){
var done = false,
offset = 0,
limit = 20;
if(!done) {
var url = "process_parts.php?offset=" + offset + "&limit=" + limit;
$.ajax({
//async: false, defaults to async
url: url
}).done(function(response) {
if (response.processed !== limit) {
// asked to process 20, only processed <=19 - there aren't any more
done = true;
}
offset += response.processed;
$("#mybox").html("<span class=\"color_blue\">Processed a total of " + offset + " parts.</span>");
alert(response.table_row);
console.log(response);
imagething(); //<--------------------------recursive call
}).fail(function(jqXHR, textStatus) {
$("#mybox").html("Error after processing " + offset + " parts. Error: " + textStatus);
done = true;
});
}
}
imagething();
【问题讨论】:
标签: javascript jquery ajax post request