Created
August 28, 2017 15:41
-
-
Save Dexdot/3fd479156b432b32527b0637372ea393 to your computer and use it in GitHub Desktop.
jquery ajax queries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function() { | |
| var userName = $('form input').val(); | |
| $.ajax({ | |
| url: './send.php', | |
| type: 'GET', | |
| dataType: 'html', | |
| data: {name: userName}, | |
| }) | |
| .done(function(data) { | |
| console.log(data); | |
| }) | |
| .fail(function() { | |
| console.log("error"); | |
| }); | |
| }); | |
| // SEND.PHP: | |
| $userName = $_GET['name']; // variable from ajax | |
| echo 'Your name: '.$userName; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment