Components
| JPromoter |
| JContentSubscription |
| JXplorer |
| JDefender |
| JUser |
Best Partners
| Mighty Extensions |
| Mighty Templates |
| Joomla Hosting |
Tutorials
Development tips and tricks
Using XAJAX in component development. | Using XAJAX in component development. |
|
|
|
| Written by Sergey Romanov | |
| Tuesday, 30 January 2007 | |
What is AjaxAjax, shorthand for Asynchronous JavaScript and XML, is a web development technique for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire web page does not have to be reloaded each time the user requests a change. This is meant to increase the web page's interactivity, speed, and usability. To use Ajax technique one need knowledge or support for (X)HTML, CSS, DOM, JavaScript. But you will not need that using XAJAX. All those technologies already implemented in to this library. You only need knowledge of PHP. And if you know JS you will probably be able to create more attractive interfaces. Good and BadRead carefully this advantages and disadvantages on AJAX. You need to know it before you plan to implement this technique on your site. Good
Bad
Because of this, you need to be very carefully to use AJAX. After you learn how to use that I am sure you will be exited and planning to implement it everywhere. That is good but remember that you can implement it everywhere but only everywhere it is compatible. I'll try to list where I plan to implement it in JCommerce component.
Because in all those action no need to keep browser history, bookmark special page or be indexed by SE. The only issue is still requirement of desktop graphical browser with JavaScript Support. I think now you know well what is AJAX and where you should and where you shouldn't to use it. Let's start and create our first component with XAJAX.First create folder com_helloworld in /administrator/components directory. Then create admin.helloworld.php file with following code
Test Me!
Download XAJAX Library, and extract xajax folder in archive to com_helloworld folder. Create admin.helloworld.xajax.php and insert following code there. alert($in);
$objResponse->assign("test_a", "innerHTML", $in);
return $objResponse;
}
$xajax = new xajax($mosConfig_live_site.
"/administrator/index3.php?option=com_helloworld&no_html=1");
//$xajax->debugOn();
$xajax->registerFunction("test");
$xajax->processRequest();
$xajax->printJavascript("components/com_helloworld/xajax/");
?>
This is will be our ajax file. All ajax requests we will process in this file. Save all files, login to back-end and call helloworld component. Use http://localhost/administrator/index2.php?option=com_helloworld URL where localhost is your http server address. Try to click on the link "Test Me!". You should see JavaScript alert with the text "Tested OK!" and link string should change to this text too. If it happened you are successfully created your xajax Joomla component. Now the XAJAX usage in Joomla limited only by your experience and imagination. I am using XAJAX to publish and unpublish records, delete records, change access, even edit some of the records. Let me describe how this code is working. If you look to http://localhost/administrator/index2.php?option=com_helloworld HTML sourse you will find there code.
This code is produced by $xajax->printJavascript('components/com_helloworld/xajax/'); line. This function include xajax JS library and define JS functions with the names you registered in line $xajax->registerFunction("test"); and prefix this function with xajax_. Now we can call our PHP test() function anywhere in HTML like this onclick="xajax_test(‘somthing');" what we actually do in admin.helloworld.php file. When we click on the "Test Me!" Link xajax make request to url defined in line $xajax = new xajax($mosConfig_live_site.'/administrator/index3.php?option=com_helloworld&no_html=1'); This calls test() function and function produce XML output by $objResponse object. XML tells to popup alert with ‘Tested OK!' text and change innerHTML of element with id=test_a to this text too. You could change $objResponse->assign('test_a', "innerHTML", $in); to $objResponse->assign('test_a', "innerHTML", date(‘Y-m-d h:i:s')); to insert time as a link text. The further application of XAJAX in Joomla depends only on your experience and imagination. Learn all XAJAX power to get Ideas on areas of application. Of course taking in account good and bad described above. Comments (6)
![]() written by Marcos Umpi?rrez, July 13, 2007
Thank??s, is very usefull
written by Karen Ajlouni, July 25, 2007
This wouldnt work in web optimization and implentation because of Java Script correct?
written by Eddy Yanto, July 25, 2007
Things might get complicated when there's a lot of administration forms, tabs and etc within. And this introductory article showed the possibility of integrating xajax in the Joomla! back-end but further output control is needed when a xajax function is getting data from files that separate html and php (content and presentation separation)
Eddy written by Arun varpe, August 03, 2007
nice !! nice logic too work with ajax based joomla
written by Arun Varpe, August 10, 2007
good tutorial for strat XAJAX .....
Write comment
|
|
| Last Updated ( Friday, 16 March 2007 ) |
| < Prev | Next > |
|---|





i need any idea for work whit this
Grtz.