Tutorial básico del método AJAX con PHP y MySQL
1. Creating the Form We first create asimple webpage that has the HTML for our Web form. There is nothing out of the ordinary here - just basic HTML defining the city, state, and ZIP code. PHP [inicio]
1. 3. < head> 4. < title>ZIP Code to City and State using XmlHttpRequest 5. 6. < body> 7. < form action="post"> 8. < p> 9. ZIP code: 10. < input type="text" size="5" name="zip" id="zip" /> 11. 12. City: 13. < input type="text"name="city" id="city" /> 14. State: 15. < input type="text" size="2" name="state" id="state" /> 16. 17. 18.
1 de 14
Leimnud Sistema de Manuales-Tutorial básico del método AJAX con...
2. Adding the Event Handler We then add an onblur event handler function named updateCityState(). This eventhandler is called whenever the ZIP code field loses focus. onblur="updateCityState();" The updateCityState() function will be in charge of asking the server what the city and state is for a given Zip code. For now, this function does nothing. We will add its guts later. PHP [inicio]
PHP [fin] 3. Creating the XMLHttpRequest Object Of course we need to create an XMLHttpRequest object. Because of variations among the Web browsers, creating this object is more complicated than it need be. The best way to create the XMLHttpRequest object is to use afunction named getHTTPObject(). This function has precompile directives which make it pretty cross-browser compatible. Don't worry if the code inside the function is unclear to you. It's not important that you understand its inner workings. PHP [inicio]
2 de 14
Leimnud Sistema de Manuales-Tutorial básico del método AJAX con...file:///D:/Tutoriales/Tutorial%20b%E1sico%20del%20m%E9todo%2...
3 de 14