Created
November 7, 2012 23:22
-
-
Save anonymous/4035320 to your computer and use it in GitHub Desktop.
Demo of a simple (useless) PHP ajax thing based on prototype.js
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
| <html> | |
| <head> | |
| <script src="http://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js" | |
| type="text/javascript"></script> | |
| <script src="validator.js" | |
| type="text/javascript"></script> | |
| </head> | |
| <body> | |
| <form> | |
| <label>Name | |
| <input id="name" type="text" name="name" /> | |
| </label> | |
| <label>ID Number | |
| <input type="text" name="idnum" /> | |
| </label> | |
| </form> | |
| </body> | |
| </html> |
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
| <? | |
| $name = $_GET['name']; | |
| print "Simon says".$name; | |
| ?> |
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 validate() { | |
| $("name").observe("blur", youblurred); | |
| } | |
| function youblurred(){ | |
| // send a request to checking.php | |
| new Ajax.Request("checking.php", { | |
| parameters : {name: this.value}, | |
| onSuccess : successFunction, | |
| method : "get" | |
| }); | |
| } | |
| function successFunction(dataPackage){ | |
| alert(dataPackage.responseText); | |
| } | |
| window.onload = validate; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment