Javascript too much recursion?

I am trying to create a script that automatically starts loading after the data has been entered into the database (I need the autoId file that the database does to load the file).

When I run javascript, the scripts launch the php file, but it cannot call another php to load the file.

too much recursion setTimeout(testIfToegevoegd(),500); 

script that gives an error

 send("/projects/backend/nieuwDeeltaak.php",'deeltaakNaam='+f.deeltaaknaam.value+'&beschrijving='+ f.beschrijving.value+'&startDatum='+f.startDatum.value+'&eindDatum='+f.eindDatum.value +'&deeltaakLeider='+f.leiderID.value+'&projectID='+f.projectID.value,id); function testIfToegevoegd(){ if(document.getElementById('resultaat').innerHTML == "<b>De deeltaak werd toegevoegd</b>"){ //stop met testen + upload file document.getElementById('nieuwDeeltaak').target = 'upload_target'; document.forms["nieuwDeeltaak"].submit() }else{ setTimeout(testIfToegevoegd(),500); } } testIfToegevoegd(); 

Sorry for the Dutch names, we have to use them, this is a school project.

when I click the button that calls it all a second time (after the error), it works fine.

+4
source share
1 answer
 setTimeout(testIfToegevoegd(),500); 

it should be

  setTimeout(testIfToegevoegd,500); 

you need to pass a function, not its result

+18
source

Source: https://habr.com/ru/post/1302992/


All Articles