|
learn xajax in 10 minutes
|
|
10-26-2009, 09:23 AM
شماره : #1
|
|||
|
|||
|
learn xajax in 10 minutes
xajax is designed to be extremely easy to implement in both existing web applications as well as new projects. You can add the power of xajax to nearly any PHP script in seven easy steps:
1. Include the xajax class library: Code: php require_once("xajax_core/xajax.inc.php"); 2. Instantiate the xajax object: Code: php $xajax = new xajax(); 3. Register the names of the PHP functions you want to be able to call through xajax: Code: php $xajax->registerFunction("myFunction"); 4. Write the PHP functions you have registered and use the xajaxResponse object to return XML commands from them: Code: php function myFunction($arg) { // do some stuff based on $arg like query data from a database and // put it into a variable like $newContent $newContent = "Value of $arg: ".$arg; // Instantiate the xajaxResponse object $objResponse = new xajaxResponse(); // add a command to the response to assign the innerHTML attribute of // the element with id="SomeElementId" to whatever the new content is $objResponse->assign("SomeElementId","innerHTML", $newContent); //return the xajaxResponse object return $objResponse; } 5. Before your script sends any output, have xajax handle any requests: Code: php $xajax->processRequest(); 6. Between your tags, tell xajax to generate the necessary J Code: php <?php $xajax->printJavascript(); ?> 7. Call the function from a JavaScript event or function in your application: Code: html <div id="SomeElementId"></div> <button onclick="xajax_myFunction('It worked!');"></pre> That's it. xajax takes care of most everything else. Your biggest task is writing the PHP functions and returning xajax XML responses from them-- which is made extremely easy by the xajaxResponse class. |
|||
تشکر شده توسط : |
Morteza, parazitt |
|
|
| قوانين ارسال |
| شما نمی توانید تایپک جدید ارسال کنید. شما نمی توانید به تایپک پاسخ دهید. شما نمی توانید فایل ضمیمه کنید. |
| کد های Html غیر فعال است. MyCode فعال است. شکلک ها فعال است. کد [img] فعال است. |


جستجو
ليست کاربران
تقويم
راهنما







تشکر شده توسط :