javascript - How to catch an Isset, or POST information, with a form in JQuery? -


so trying simple. there form, self post , want post information jquery , put div.

    <!doctype html>       <html>         <head>          <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">           <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>           <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 

jquery here catch button click , "php_self":

        <script>         $(document).ready(function(){             $(".gettingpostbutton").click(function(){                     $.post( "<?php echo htmlspecialchars($_server["php_self"]);?>", function( data ) {                         $("#add_post_information_html_here").append(data+" number $_post");                     });/**/             });         });         </script>         </head>     <body>        <?php     // define variables , set empty values     $number = "";      if ($_server["request_method"] == "post") {       $number = test_input($_post["number"]);     } 

for sql injection:

    function test_input($data) {       $data = trim($data);       $data = stripslashes($data);       $data = htmlspecialchars($data);       return $data;     }     ?> 

basic form:

    <h2>php form validation example</h2>         <form method="post" action="<?php echo htmlspecialchars($_server["php_self"]);?>">             put number: <input type="text" number="number">           <br><br>             <input type="button" name="action" class="btn btn-success gettingpostbutton" value="add number" />          </form> 

put info page either through php prefer through jquery:

    <?php     echo "<h2>your input:</h2>";     echo $number;     ?>      <div id="add_post_information_html_here"></div>      </body>     </html>     result: 


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -