I really love the simplicity of xajax calls from PHP, however xajax project seems dead by now... Is there any nice alternative or equivalent to xajax which is actively in development?
+1
A:
Yes, please have a look at PHPLiveX. It is light-weight, and there with the continued development. Thanks
Example Code:
function generateRandomCode($length){
$chars = array("1","2","3","4","5","6","a","b","c","d","e","f");
$code = array_rand(array_flip($chars), $length);
return implode($code);
}
// Necessary PHPLiveX Codes
include("PHPLiveX.php");
$ajax = new PHPLiveX(array("generateRandomCode"));
$ajax->Run(); // Must be called inside the 'html' tags.
<input onclick="generateRandomCode(10, {'target':'rcode','preloader':'pr'});"
type="button" value="Generate Random Code" >
<img id="pr" src="design/Progressbar2.gif" style="visibility:hidden;">
<span id="rcode"></span>
Sarfraz
2010-01-24 08:23:56
I can see the last release date older than xajax o.O The forum is also cold... Is it really still actively in development?
TheOnly92
2010-01-24 08:26:11
+1
A:
Well, in all my project, I write all javascript code using jQuery. It's a very powerful javascript library that have complete arsenal of DOM manipulation and AJAX request code build-in it.
There are several attempt to encapsulated jQuery into php, so the jQuery code can be called inside php code, and the corresponding jQuery code will be included into page output. But for myself, I prefer to write all javascript code inside the script
tags in the view
file (I use CodeIgniter).
jQuery is actively developed, and the latest version (1.4) is just launched a few days ago.
Donny Kurnia
2010-01-24 09:21:14
Thank you for your answer, I was also thinking about using jQuery, do you have any more examples for encapsulating jQuery into PHP?
TheOnly92
2010-01-24 10:04:23
Just click my link above: http://jquery.hohli.com/ I don't know much about it, since like I write in my answers, I prever write javascript in the page, not in PHP code, because that's what work for me all this time. Since I also use CodeIgniter, I can keep the controller code at minimal with this way.
Donny Kurnia
2010-01-24 13:27:08
By writing the javascript code in html output file part, I can test the code in the static html, before put it in actual PHP code. The template is usually provided by other colleague or my client, so I just concentrate on js code and PHP in back end. I make it work without js first, then do progressive enhancement with js code. That's another reason why I put js code in html, not in PHP backend, since it's just to enhance, not the main feature. Without it, my application still can work.
Donny Kurnia
2010-01-24 13:30:34
I have a project where it has been relying heavily on xajax since the beginning. It will be very difficult to switch into just using jquery since there will be a lot of additional javascripts needed in pages. Just to make our work lighter, I need to find an alternative to it.
TheOnly92
2010-01-26 11:48:03
My suggest is that you do progressive update, rather than replace all of it. For now, leave the already worked page, and use jQuery for new page, so you can learn while use it. It will help you understanding the jQuery more better. After you successfully create new page, then start to convert existing pages, one at a time from xajax to jQuery. After this go smooth, in your next project, you can safely start using jQuery since beginning. Just a suggestion, since this is what I do the first time I learn jQuery a few years ago.
Donny Kurnia
2010-01-26 13:41:26