Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #index.php file:
- <!doctype html>
- <head>
- <script src="jquery-1.11.3.min.js"></script>
- </head>
- <body>
- <script>
- $('form').submit(function(){
- $.ajax({url: "magic.php",
- data: {variable : $('#variable').val()},
- success:function(data){alert(data);});
- return false;
- });
- </script>
- <!-- form -->
- <form action="magic.php" method="POST">
- <label for="domain">Unesite varijablu:</label>
- <input type="text" name="variable" id="domain" />
- <input type="submit" value="trazi" name="submit" />
- </form>
- </body>
- </html>
- #magic.php file
- <?php
- /*
- *
- * fetch variable with POST
- */
- $variable = $_POST['variable'];
- function doMagic($variable) {
- return "Variable value is $variable";
- }
- $data = doMagic($variable);
- return $data;
Advertisement
Add Comment
Please, Sign In to add comment