[英]Why does AJAX is so long?
Hi all i'm trying to compile and send some forms to a php file, but i noticed that it's very slow, even if in PHP i var_dump only the POST values, it takes the same time if i run with my correct functions.大家好,我正在尝试编译一些表单并将其发送到 php 文件,但我注意到它非常慢,即使在 PHP 中我 var_dump 仅 POST 值,如果我使用正确的函数运行它也需要相同的时间。 Maybe the code is wrong, this is what i'm trying to do:
也许代码是错误的,这就是我想要做的:
$("#button").click(function(){
$("#button").css("border","2px solid blue");
var total_forms = $("input[name=total_forms]").val();
$.ajax( {
type: "POST",
url: "<? echo "myurl.php";?>",
data: {delete : 1}, //before sending my forms i need to run another function that delete some items in mySQL DB
success: function(data) {
for(var i = 0; i < total_forms; i++){
var string_ok = "#form_number_";
string_ok = string_ok.concat(i);
var dataString = $(string_ok).serialize();
$.ajax( {
type: "POST",
url: "echo "myUrl.php;"",
data: dataString,
success: function(data) {
console.log(data); //it's a bit faster, only a bit
$("#mydiv").append(data); //it's a bit slower
}
});
}
}
});
});
I forget to say that i'm running it on MAMP in a macbook with 8GB RAM and SSD with only 10GB free, maybe my PC is the problem, IDK..我忘了说我在 macbook 上运行它,它有 8GB RAM 和 SSD,只有 10GB 免费,也许我的电脑是问题,IDK..
it takes about 4minutes to compile, send to PHP and stamp datas for 500forms编译,发送到PHP并为500个表单标记数据大约需要4分钟
this is an example of dataString that i send:这是我发送的 dataString 示例:
prd_number=1259&prd_max_number=1763&old_prd_id=0&prd_action=true&title=INFORMAT%20G1X85A%23A80&title_check=true&old_title_text=&new_image_url=&old_image_url=&is_mech=&image_check=true&new_cat=Informatica%2CINFORMAT&category=true&new_price_text=222.04&price=true&new_sku_text=888182658918&oth=true&ncw=negat&stwe=testing&mark_text=INFORMAT_G1X85A%23A80&check_two=true&other_sto=table&var2=true&elemt=&weight=true&qt=3&qslow=true&clients=Norman%2Cli&taking=true&setting=normal&vars_set=true
i noticed that if i console.log(dataString), the console first stamps all dataString logs, and then starts to print each php response.我注意到,如果我使用 console.log(dataString),控制台首先会标记所有 dataString 日志,然后开始打印每个 php 响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.