Let's analise the diference, I'm not going to do the necessary "include files" since xajax and jquery only need 1/2:
Load a php function into a div with xajax:
PHP INITIAL ROUTINE $xajax = new xajax();
$xajax->registerFunction("processFormData");
//$xajax->setFlag("debug", true);
$xajax->processRequest();
$Xjavapath=XOOPS_URL.'/modules/tutorial/class/xajax';
$xajaxjava=$xajax->getJavascript($Xjavapath);
$xoopsTpl->assign('xajaxjava', $xajaxjava);
PHP FUNCTION function processFormData($arg)
{
$newContent = "Value of field: ".$arg['myfield'];
$objResponse = new xajaxResponse();
$objResponse->assign("thisID","innerHTML", $newContent);
return $objResponse;
}
HTML PART <{$xajaxjava}>
<div id="thisID">div>
Now with ajaxify:HTML PART <a class="ajaxify" href="phpfunc.php?tst=123" target"#container">The easy waya>
PHP FILE WITH PHP FUNCTION function ajaxy($arg)
{
$Hello="welcome to my world at $arg";
return $Hello;
}
$tst=ajaxy($_POST['tst']);
echo $tst;
Now the xajax part has incomplete code since I'm missing a function to trigger on mouse click, while the ajaxify code has this. While I like to use this jquery plugin, You could just as easily have done this with jquery alone (without plugins).
Initially, I was a little hesitant from switching away from xajax; First because I wasn't familiar with javascript and was a little fearfull of jumping into another language, god knows how much learning it's taken to understand PHP. Second, why leave xajax if I'm profiecient at it? For the first reason, javascript really isn't that hard to learn if you already understand PHP. The basics are quite similar. The second part has a 2 part answer:
1- Simplicity! With xajax you are required to create a xajax function that serves as an conection between javascript and PHP ($xajax->registerFunction). Now when designing with xajax, all calls HAVE to go back to the server. So you are not really taking advantage of javascript wich is a client based language. For instance, you have a table of data and you want to sort by column's. Using old Xoops, you would create an image link that would do a new DB query and reload the whole page. With Xajax, you still do the DB query but only reload the table. With Javascript, once the table is loaded on the client he can sort it as he pleases without any further DB queries! This is great because it's less load on the server. So now you can benefit from javascript, and when necessary do ajax calls to get PHP code.
2- Less code/ faster development. Since I've switched (after an initial learning curve about the basics of javascript) I've been coding with ajax much quicker and taking advantage of an incredible library of plugins available to jquery! Just look at (
http://jqueryui.com/demos/draggable/) to see some standard plugins/effects that come with Jquery. Also, since it's a framework, you can easily add more and more plugins to your page. Of course it's not perfect. There are some issues you do run into. However you can use firebug.js and frankblack's great module to troubleshoot any problem either in php or javascript.
I'm going to post a list of useful jquery plugins if people are interested. I've already written a jquery tutorial that's available on my site on how to create XOOPS admin menus. I'm thinking of creating a new one that's more of a beginners guide to javascript.