When I make an Ajax request to my server-side script, it inserts two records concurrently, when I only called submission event once under page:afterin hook.
I can’t seem to figure where that problem is coming from? Below are screenshots of my code
When I make an Ajax request to my server-side script, it inserts two records concurrently, when I only called submission event once under page:afterin hook.
I can’t seem to figure where that problem is coming from? Below are screenshots of my code
Because you are using live
/delegated
event listener. Change your:
$$(document).once('submit', 'form#crud_order', function() {
to
$$('form#crud_order').once('submit', function() {
Thanks @nolimits4web
But i think I was calling the execute() method of PDO class twice in my server script.
Like:
Line 1. $query->$this->connect()->prepare(“insert-sql-statement”);
Line 2. $query->execute();
Line 3. return $query->execute() ? true : false;
So its gets executed on Line 2, and again executes when checking the condition on Line 3, hence double insertion,
I just took my time to debug it line and by line and nipped it in the bud.