| ||||||||||||||||||||||||||||||||||
|
![]() HTML_AJAX In operation 1. Intro. Files to clause{article}: html_ajax.rar < =http%3A%2F%2Fwww.realcoding.net%2Fdownloads%2Fhtml_ajax.rar> HTML_AJAX It was specially developed for simplification of development of applications using technology AJAX (Asynchronyse Javascript And XML). The technology enough for a long time already became popular and it is no wonder. Personally I have seen for myself economy of the traffic, and absence perezagruzki pages that should please an eye, any copying of figures, look and there are news, has pressed the button, and informer informed for you, that your recording in blog is successfully added, and you really already see her{it} in the list of last recordings. Dream for user, and us developers actually is necessary to carry out her{it}, and to follow a principle, that is pleasant for the user to the developer updating of the bill. Why HTML_AJAX? Let's be defined{determined} at once, and we shall look in the progressive future. HTML_AJAX superb uses classes, on it and we shall play. At present as far as I done not deceived with memory there is already development PHP6, shall see at result. I use following combination PHP5+HTML_AJAX. If PEAR at you it is established, actually we take the given package from here http://pear.php.net/HTML_AJAX. < =http%3A%2F%2Fpear.php.net%2FHTML_AJAX.> In any other case you can simply download archive, unpack it{him} in a convenient place and not forget in ini a file to register include_path to the given package. 2. A simple example and deviation with the introduction. For the beginning I shall simply show example HTML of page. <html> <head> <title> HTML_AJAX Example </title> </head> <script src = " server.php5? client=all*stub=user "> </script> <script> function checkName (f) { var u = new user (); var t = document.getElementById ('tgt'); if (u.checkname (f.username.value) == true) { tgt.innerHTML = ' You can register this username '; } else { tgt.innerHTML = ' This username is already in use '; } return true; } </script> <body> <div id = "tgt"> </div> <table> <form onsubmit = " return! checkName (this); "> <tr> <td> Username </td> <td> <input type = "text" name = "username"/> </td> <td> <input type = "submit" value = " Check this name "/> </td> </tr> </form> </table> </body> </html> Remember, how much time to you was necessary to register to itself a mail box, or in general simply to be registered at any forum? You come on page of registration, fill in all fields as the decent user press "To be registered" and, the sanctum, after everything, that you filled, not only that values of fields are not saved so also your everywhere used name in a network is borrowed{occupied}. The order? Certainly, no! Naturally any programmer should think of convenient registration. Eventually, for whom we write and trudimsja? Yes certainly for itself and naturally the list of actions which are necessary to be registered you know only, and anothers should explain. But it so, sore. I have knowingly started talking about convenient registration. Zajdja on the form of registration, the user can naturally be lost in that quantity{amount} of fields which you can offer him. Personally I prefer to request only the most necessary fields which are really necessary for registration, and the rest to leave on then, but periodically to remind or put a reminder somewhere on not so appreciable place, that the profile of the user is not filled. Let's return to our example. What does he give? Basically actually anything, but it is rather useful. What we interestingly also would like to clear? The class user with a method checkname () whence has undertaken? For this purpose we shall see at '3' line. He is rather voluminous, but while on it we shall not reflect. 3. Creation of the server Actually the script also is the server which serves ours AJAX searches, processes the data. To use it{him} it is rather easy. <? php require_once 'HTML/AJAX/Server.php'; class user { public function __ construct () {} public function checkname ($username) { // some query to db to check on existing username $username if ($username == 'md5hash') return true; else return false; } } $user = *new user (); $srv = new HTML_AJAX_Server (); $srv-> registerClass ($user); $srv-> handleRequest (); ?> We create a class user and class HTML_AJAX_Server to which we pass the index to a class which we want to use in the AJAX searches. Function username () can address to a database and look at presence in the table of the user with a name $username. We for an example mean, what any name, except for my darling is free?. 4. Outro. Unfortunately, the idea is wide, is especial if to take into account questions of registration, but is voluminous and probably to you will want to make something. That is rather convenient, so that that at all searches in a right top corner appears a layer with inscription Loading … speaking about that that all works as it is necessary. |
|||||||||||||||||||||||||||||||||