If you want to call two javascript functions in an onclick event ( or any other event ) , just place them after eachother, seperated by a semi colon.


var obj = $("#my").val();

<ol id="my">


I guess you should either do it with the getformvalues function (and put everything between <form> tags) from xajax, or stringify the javascript array ( google for it, should be something like converting javascript array to a json string).
The json string can be sent to the server and in php you could json_decode the whole stuff.

Your "wish" is a browser feature..
I am using jquery standard, and used some jquery code to attach an key-event to the input.
If the result of the keystroke == 13 (enter button) , it submits the document.

so, i guess you are not doing anything wrong, it's just the browser acting in some way, which you have to bypass.


(1 replies, posted in Getting started with xajax)

put out or return an iframe in your response, with a link to the pdf document.

In addition you could google for the keywords iframe pdf


in xajax there isn't one, as i know.
Maybe you should take a sneak peak  at jquery which can select them in one statement, which can be send over with xajax to the server.

From the php point of view... Sure ... Why not ? 
Just have a session started with each call to the php script.

Allrighty... got two small patches to this..  These are not tested in combi with xml responses...

xajax_core.js in xajax.processParameters = function(oRequest)

if ('object' == typeof oVal && null != oVal) {
                try {
//                    var oGuard = {};
//                    oGuard.depth = 0;
//                    oGuard.maxDepth = oRequest.maxObjectDepth;
//                    oGuard.size = 0;
//                    oGuard.maxSize = oRequest.maxObjectSize;
                    //oVal = xt._objectToXML(oVal, oGuard);
/* altered part */
                                        for (i in oVal) {
                                            if (typeof oVal[i] == "object") {
                                                oVal[i] = eval("({" + oVal[i].join(',') + "})");
/* until here */
                                        oVal = JSON.stringify(oVal);

                } catch (e) {
                    oVal = '';
                                        if (debug) {
                                            console.log("Params " + e.message);
                    // do nothing, if the debug module is installed
                    // it will catch the exception and handle it
                oVal = encodeURIComponent(oVal);
            } else {

xajax_core.js in  xajax.tools._getFormValue = function(aFormValues, child, submitDisabledElements, prefix)

    if (0 <= keyBegin) {

        var n = name;
        var k = n.substr(0, n.indexOf('['));
        var a = n.substr(n.indexOf('['));
        if (typeof aFormValues[k] == 'undefined') {
            aFormValues[k] = [];

        var p = aFormValues; // pointer reset
                while (a.length != 0) {
            var sa = a.substr(0, a.indexOf(']')+1);
            var lk = k; //save last key
            var lp = p; //save last pointer
            a = a.substr(a.indexOf(']')+1);
            p = p[k];
            k = sa.substr(1, sa.length-2);
            if (k == '') {
                if ('select-multiple' == child.type) {
                    k = lk; //restore last key
                    p = lp;
                } else {
                    k = p.length;
/*altered part */
            //if (typeof p[k] == 'undefined') {     
            //    p[k] = [];
        p.push( '"' + k + '":"' + values + '"' );
/* until here */
    } else {
        aFormValues[name] = values;

I've been testing on this point, and the current setup has some drawbacks which require a rewrite of some parts.
It also looks like the json.stringify can't handle multi-dimensional arrays.  Can someone verify this ?
If so, then this function isn't usable with form values.

I have the same problem..   Lets try to describe the problem as i see it..

lets say i have a html tag like :
<input type="checkbox"  name="sel[6000]" value="dunno" >

In this case xajax wil post a json string with values :
sel[0] = null, sel[1] = null  ....... sel[5999] = null, sel[6000] = 'dunno'

In the xml case, you only became the sel[6000] value.
To put is short..  the javascript has to  ignore all the null values.

Update :
What i found next :
bla = []
bla[10] = "dunno"

this gives the string  [undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, 10]

Looks like some unwanted drawback of json to our needs...


(15 replies, posted in Beta Section)

I compared quite a few things, but some things are still completely PHP4.  I Haven't checked if the code is used in some way.

My feature requests or call it improvements are still wanted by me in the official release wink
Here i'm talking about :
-- Specify which methods are used in case of a XAJAX_CALLABLE_OBJECT
-- In stead of supplying an object, just supply the class name as a string. This gave a speed improvement for me. 
-- Remove the javascript compiler function and use the google closure compiler ( http://code.google.com/intl/nl/closure/compiler/ )
    Using this compiler yields some little syntax warnings in the 0.5  release.. I haven't tried the latest version yet.
-- Make the dir of the xajax javascripts user definable in stead of a subdir beneath xajax dir.

The code is available.. just give a yell wink

Allright.. definitly not a bug as i have seen now.
As you can see, i'm using jquery.

To prevent and to inform :
This is NOT gonna work because of the \n (newline).

$('body').prepend('<select name="u_id">\n</select>\n');

Instead use:

$('body').prepend('".addcslashes(<select name="u_id">\n</select>\n' , "\r\n\t")."');

Today i was puzzeled with this error :

{"xjxobj":[{"cmd":"js","data":"$('body').prepend('<select name=\"u_id\">\n<\/select>\n')"}]}

The error i got was an unterminated literal string. At first the string seems ok, but the newline is the bad guy here.
In xaxaxresponse there's this line :
$bSpecialChars = (htmlspecialchars($sData, ENT_COMPAT, 'UTF-8') != $sData);   
So, all quotes and doublequotes are slashed.

What i am asking now : in javascript ( script command in xajax), the data string in the response also has to add slashes to newlines and form feeds.

Is this correct, or is this part not implemented for some reason ?

For now, i'll adjust the xajax code.

Try pulling the <div> part to your script.
Something like this perhaps ??

$respuesta = new xajaxResponse();
if ( $salida = ""){ 
  $respuesta->assign($div, "innerHTML", "");
else {
$respuesta->assign($div, "innerHTML", "<div>$salida</div>");
return $respuesta;           


(2 replies, posted in Troubleshooting)

Yeah, sure do...  I few clicks @ google don't seem to give an answer either, so putting in on mozilla plate would be a good thing..

Most of the docs don't give that much information.
Maybe the api-docs give enough information for you (http://xajaxproject.org/en/docs-tutorials/api-docs/)
but i always browse the source code to see how a function really works.
A bit of javascript knowledge is mandatory i would suggest.

And otherwise, you are always welcome to post your questions on this forum


(4 replies, posted in Release Testing)

There are some more little small issues which i fixed in my local repository.

At the moment, i completely outcommented the javascript compressor in the php code.
Now i use this one : http://closure-compiler.appspot.com/home
Beware : you can only use the whitespace only options, since the others do some optimizings which are unwanted.

Why i use this one ?  Don't re invent the wheel i would say wink

instead of printjavascript(), you should use getJavascript(), which returns the output as a string...


(5 replies, posted in Troubleshooting)

You have to merge both of them (style.php and "myfile")

Code: PHP


function replace($arg)


    $newContent = "<img src='".$arg."' />";

    $objResponse = new xajaxResponse();

    $objResponse->assign("div123","innerHTML", $newContent);

    return $objResponse;


$xajax = new xajax();



print ('some html code');

$xajax->processRequest(); ?>

Let's say you have to keep in mind :

For outputting html , the next part is mandatory :

$xajax = new xajax();



print ('some html code');

And to process a xajax response :

$xajax = new xajax();



So you see the next code must be present in both cases.

$xajax = new xajax();

Can't remember in which situation i had this, but i have expirienced this myself also.
For some reason, the xml wouldn't be parsed anymore because of some weirdo char, which i couldn't find in the string offcourse.

Seems you have hit this flaw also, from which i believe is not a bug in xajax but in the javascript/ php xml parser. (or simply one of them)


(5 replies, posted in Troubleshooting)

where is the $xajax->processRequest() ??

This is your error : ResponseReceived: Invalid response XML: The response contains an unexpected tag or text: {data}.

When i look at the source in javascript, the cmd tag above should be processed but it isn't

My guess is, that there is some unwanted whitespace anywhere in the response xml.
For that you should check your php code.

look at this thread also :
http://community.xajaxproject.org/topic … urned-xml/

Your syntax is wrong..    with a callable object, you should specify to which method the callback should be "attached".

An example with a page class i have.

   class clsPage {

  public function SetItemsPage() {
 public function SetSort( $sort ) {
  $Params = array('SetItemsPage'  => array('mode' => "'synchronous'"),
                        'SetStartPage'  => array('mode' => "'synchronous'"),
                        'SetFilter'     => array('mode' => "'synchronous'"),
                        'ResetAll'      => array('mode' => "'synchronous'"),
                        'ResetFilter'   => array('mode' => "'synchronous'"),
                        'ResetSort'     => array('mode' => "'synchronous'"),
                        'SetSort'       => array('mode' => "'synchronous'"));

        $GLOBALS['rfPage'] = $xajax->register( XAJAX_CALLABLE_OBJECT , new clsPage  , $Params );

I made some changes to the core on the XAJAX_CALLABLE_OBJECT part.
Now it is not necassary to pass an object instance. Just a string from the wanted classname is enough.

Beacuse i inherit quit a few classes, the changes gave a significant improvement in speed.

It is not the real solution but just a supression of the real error.
In php 5 a creation of an instance with new is already a reference. In php4 you had to reference it yourself with &.

Because in 5.2 it is deprecated, you get a non fatal error.

i think it basicly comes down to this : http://www.smarty.net/manual/en/plugins … ntions.php

But i think, my way is beter, describe the method you want to use.
My idea is also, to minimize the javascript more, by using this dynamic implementation. Just look out for security leaks wink