简体   繁体   English

在收到前回复后,逐个调用ajax

[英]making ajax call one by one after receiving the ex-response

I have many input type of checkbox in my html page. 我的html页面中有很多输入类型的复选框。 Those checkbox are checked by user must be sent to server but not in the burst way. 用户检查的那些复选框必须发送到服务器,但不能以突发方式发送。 I mean for example, user checks 10 inputs, the first one is sent to the server waiting for the first response, then second send, and so on ... . 我的意思是,例如,用户检查10个输入,第一个发送到服务器等待第一个响应,然后第二个发送,依此类推...... My problem is at the first time all the input sent without being waited for the first response. 我的问题是在第一次发送所有输入而没有等待第一个响应。

I'm using jquery and php localhost 我正在使用jquery和php localhost

$(document).on('click', '[data-snapshots="run"]', function(){
                    var jParent = $('#AllDiagramsInProjectModal');
                    var jSelf = $(this);
                    jParent.find('[data-get-snapshot-diagram-id]').each(function(i,v) {
                        var nDiagrams= [];
                        if ($(v).prop('checked') === true) {

                            DiagId = $(v).attr('data-get-snapshot-diagram-id');
                            SnapProjectId = $(v).attr('data-spanshot-project-id');

                            console.log("Running all snapshot (" + DiagId + "," + SnapProjectId + ")");
                            //make_an_ajax_call(DiagId, SnapProjectId);
                        }
                    });

                });

您需要管理您的ajax调用,如jAndy所述 :已回答: 使用jQuery.queue()队列ajax请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM