Onload issue keeps looping

hi i have the script and i want it to load once it just keep looping

<body onload="document.frm1.submit()">
   <form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="frm1" method="post">
      <input type="hidden" name="keyword" value="<!-- BEGIN cat_random -->{cat_random.CAT_ID}<!-- END cat_random -->" />
                              <input type="hidden" name="csrftoken" value="{_CSRFTOKEN}">


need assist thanks

I guess that when you submit the form you cause a page reload. When the page reloads, you submit the form and so on…

The best thing would be to catch the submit event, prevent the browser’s default action (submission, in this case), then do Ajax. Something like this (assumes jQuery):

const myForm = $('#myForm');

myForm.on('submit', (e) => {

    method: 'POST',
    url: 'whatever.php',
    dataType: "json",
    data : $('#myForm').serialize(),
    success: (data) => { ... },
    error: (err) => { ... }
1 Like

thanks 4 d assist_

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.