Topic: The future of Xajax!

Hello community,

I'd like to start a discussion to hear your concerns and suggestions about Xajax. What problems should we adress next? How can we help you to make your life as a developer easier?

The most wished feature from the past is: JSON responses! We've already implemented it in the 0.6 dev-branch and are going to extend the support even further. Currently the Comet and SWFupload plugin aren't compatible to JSON responses, but I'm going to change that before the first official release candidate of xajax 0.6

The second most wished improvement was concerning the size of the javascript script core. In the current dev-branch we already got the rid of all depracted functions we were carrying around since xajax 0.2. The size shrinked significantly, but there's still some room for improvement.
One of the ideas to shrink the core even further is to build a compile feature and interface. With the compile feature you could easily customize the javascript core to fit exactly to your needs. All unneccessary response functions and transports (json vs xml) could be dropped from the core by re-compiling the javascript core.

Another suggestion was "improve the speed!". That's indeed a good and important point. Apparently registering hundreds of functions per script call turns out to pretty slow. We are definitely going to adress that!

Furthermore, we'd like to give u the possibility to directly call your javascript libraries like JQuery through the reponse class.
For instance, a jQuery call could be triggered this way:

$objReponse->jQuery('#mydiv')->html('New content<br />for my div')->fadeIn();

At the moment it's only an idea for the future roadmap and open for discussion!

What do you think? Is there anything else you'd like to see? Let us here your suggestions!

Re: The future of Xajax!


I only register one function any more:

function dispatch($func, $data='')
  if (function_exists($func))
     return $func($data);
    $objResponse = new xajaxResponse();
    $objResponse->alert("$func is not a defined function");
    return $objResponse;

This is the non-oop form.

In a class it is a function and I use registerCallableObject() and dispatch() is the only public function.

As for jQuery, I use the response's script() function and it works quite well...


If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: The future of Xajax!

I hope this is only a shortened example of what you'r doing Ed. function_exists() also evals to true for "shell_exec" and so on.

Please tell me your scripts aren't THAT insecure smile

However, I do understand how u ended up with this approach and I somehow like it..except for the fact that your function validation example is not avisable at all wink

Ed, the reason for the JQuery idea is to have clean syntax. I know ->script() is a powerful function that can be use to execute anything on the client, but one of the main purposes of xajax is to reduce amout of hand-written JavaScript to a minimum. smile

Re: The future of Xajax!

Yes. I use get_defined_functions and check in the user function array...

In a class I use method_exists().

I have taken to using Codeigniter with xajax and smarty lately. Works really nice together...

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: The future of Xajax!

The compile feature:     

Ability to change maxObjectSize and responseQueueSize. Ability to let the user decide wether XHR requests should be detected via



< element=xajax.$(element);;;eval('element.'+sEvent+' = function(event) { '+code+'; }');return true;}
> element=xajax.$(element);;;eval('element.'+sEvent+' = function() { '+code+'; }');return true;}

The missing event in the original 0.5 code is a problem if you expect the event variable in your JS code called by xajax. (e.g. onclick event)     

One problem for me: DOM structures created by xajax by a new class that was never before created via GET request, is not part of the registered objects so xajax says unknown if you call top.xajax_MyNewClassCreatedDynamically. How can I achieve the JS pendant of ->register(XAJAX_CALLABLE_OBJECT ?? Maybe a function already exist to update the internal table or a new feature?

Today I'm under the constraint that I have to register the object reference of all classes maybe used afterwards on the first GET request.
Because I'm using consequently PHP objects that's could be a memory impact sometimes.

6 (edited by neokio 2012-05-11 7:04:58 AM)

Re: The future of Xajax!

Hi q_no + ed + crew,

I also think that $res->script() is perfectly effective for jquery calls. While I can imagine a few ways that adding jquery methods to Xajax might be cool, why reinvent the wheel? I think in the long term it would distract you guys from the goal: improving and innovating Xajax smile

Here's my biggest wish for Xajax: GET IT WORKING WITH OUTPUT BUFFERING!
Below is a simple demonstration of a problem that has crippled how I work with Xajax for the last 4 years:

    // With processRequest() on line 23, this works fine.
    // But if you make this call after a bit of OUTPUT, it breaks.
    // Test by commenting line 23 out, and UN-commenting line 40.
    // This demonstrates that Xajax does NOT work with output buffering.

    require 'lib/xajax_core/';
    $xajax = new xajax();
    $xajax->configure('javascript URI', '/assets/js/' );
    function test()
        $res = new xajaxResponse();
        $res->alert('HELLO WORLD');
        return $res;
<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8" />
    <title>TEST 1</title>

<a href="#" onclick="xajax_test();return false">Click to test Xajax</a>


    $xajaxjs = $xajax->getJavascript();
    $buffer = ob_get_clean();
    $buffer = str_replace('{XAJAX}', $xajaxjs, $buffer);
    $buffer = str_replace('{H1}', 'BUFFER IS ON', $buffer);
    echo $buffer;

Why is this a problem? About 80% of my xajax functions are single-page-use, the rest are fairly global. Some of my more complex sites have hundreds of Xajax functions. With output buffering broken, I'm forced to put ALL of my functions in one file, instead of placing them in the specific .php files from which they are called. Yes, everything works, but it makes my code sloppy and annoying to debug. And to avoid the inefficiency and potential security risk of loading xajax functions I don't need, I have to use if/else conditions in my one giant Xajax function file.

No big whoop, but rather inelegant. And that being said, I can't imagine coding without Xajax. Long live Xajax!

Re: The future of Xajax!

Happy to hear that XAJAX has a future!

Maybe update and better document the table updater plugin for better dynamically table manipulating?

Re: The future of Xajax!

I am very glad that you continue with xajax.

Now, I use xajax for several years. I do not want to miss it smile

I must agree neokio's statement about jquery.
$ res-> script () is easier to cut & paste of jquery/js code, change some quotes and double quotes, that's it.
Or vice versa, copy code into browser development tool for testing.

Leave it as it is !

I have no problems with output buffering.
The number of xajax functions is a matter of code design. I use one xajax function per class and give an extra action parameters and in my php class I decide what function to call. I register the xajax functions in the class in which they are located.

My wish would be a different plugin for file upload instead swfupload that use flash. IMHO flash is outdated. valums file-uploader is a good choice. I'm trying to implement it in xajax getFormValues(), so far without success. sad