Created
April 13, 2014 13:27
-
-
Save ruliarmando/10584104 to your computer and use it in GitHub Desktop.
ajax frontend
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
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>Ajax WebService</title> | |
| <script src="jquery.js"></script> | |
| </head> | |
| <body> | |
| <form id="calc"> | |
| <input type="text" name="operand1" /> | |
| <select name="operator"> | |
| <option value="+">+</option> | |
| <option value="*">*</option> | |
| <option value="-">-</option> | |
| <option value="/">/</option> | |
| </select> | |
| <input type="text" name="operand2" /> | |
| <input type="submit" id="submit" value="Proccess!"> | |
| </form> | |
| <br /> | |
| <br /> | |
| <input type="text" id="result" readonly /> | |
| <script> | |
| $(document).ready(function(){ | |
| $('#submit').click(function(e){ | |
| e.preventDefault(); | |
| $.ajax({ | |
| url: 'main.php', | |
| type: 'post', | |
| dataType: 'json', | |
| data: $('#calc').serialize(), | |
| success: function(data){ | |
| $('#result').val(data.result); | |
| }, | |
| cache: false | |
| }); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment