Can .trigger be used to drive post / submit

Viewed 13

I have a razor page with input as shown ( it drives a post Event handler PostAutoUpdate) The idea is to drive the request for update every 5 seconds. The script is working to cycle the function but trigger syntax is either incorrect or it cannot be done. There is an alternate .post method but I need more than the URL, need to drive it to the server's handler. The trigger seems clean but ... doesnt seem to work in my many variations. Is it possible ? How ?

<body>   
    <form name="myUpdate" asp-page-handler="AutoUpdate" method="post">
         <input type="submit" id ="testAuto" name="AutoUpDate" value="Go" class="btn btn-primary">
    </form>
</body>
@section scripts{
    <script>
        let sampleRate = 5000;
      $.ajaxSetup({ cache: false });  //clear browser cache.
        refreshInterval = setInterval("my_function();", sampleRate);  
         function my_function() {
          $("#testAuto").trigger("submit"); // none of these work to do post...
          $("#testAuto").trigger("submit");
          $('#myUpdate').trigger("submit");
          $("#myUpdate").trigger("submit");
          $().trigger("submit");
          $("input").trigger("AutoUpdate");
          alert(" executed beyond #testAuto")
         }  
</script>
    }
0 Answers
Related