how to write javascript code inside php

前端 未结 4 1544
轻奢々
轻奢々 2020-11-28 08:23

i have a got a form, on clicking the submit button:

  1. I want to do some task in the same file (db task) AND
  2. I want the form data to be sent to test.php
4条回答
  •  有刺的猬
    2020-11-28 08:35

    You can put up all your JS like this, so it doesn't execute before your HTML is ready

    $(document).ready(function() {
       // some code here
     });
    

    Remember this is jQuery so include it in the head section. Also see Why you should use jQuery and not onload

提交回复
热议问题