Many thanks, Jamal.
1.)
I went one step back and tried to submit all forms manually. When clicking very fast on all the submit buttons manually, not all forms were saved, even though Ajax wheel was spinning and confirmation message was shown. This does not seem right.
In console I see all the admin-ajax.php requests, all with success but only for some forms a post was created, which was the forms goal. (When I reload selected admin-ajax.php requests, the missing posts are created.)
Is this something you could look into? I could provide access to my instance.
If needed: PHP Version 7.4.13, memory_limit 4096M
2.)
So in general the delay option seems right as a workaround to solve this issue but also seems not very reliable at the same time.
I changed my script a bit to have a different button (id mybutton) submitting all the forms and included your delay.
When I click that button with id mybutton, all forms get submitted , but apparently all at the same time with no delay in between. I also tried to change 100ms to 1000ms. Nevertheless, again, all admin-ajax.php were a "success", but only some posts were created.
In total my view outputs 10 forms at the same time. When submitting one form, a post should be created.
This is how many times I have to clicked on the button with id mybutton, to really have all the forms submitted and created
1st try:
1st. click on button with id mybutton: 3 posts created
2nd. click: 2 posts created
3rd. click: 1 post created
4t. click: 1 post created
5th. click: 1 post created
6th. click: 1 post created
7th. click: 1 post created
2nd try:
1st. click on button with id mybutton: 5 posts created
2nd. click: 1 posts created
3rd. click: 2 post created
4th. click: 2 post created
Code used:
HTML:
<button id="mybutton">Submit all</button>
JS within the view:
( function( $ ) {
$( document ).ready( function(){
$("#mybutton").click( function( event ){
var i = 0;
setTimeout(function(){
$(".btn-submit").click();
}, (i++) * 100);
});
});
})( jQuery );
Not really that familiar with JS, would be great if you could look into 1) if it is a general issue and 2) if you could look into the code again to create a working solution in the meantime.
Many thanks
Bernhard