Topic: Error: the xajax Javascript component could not be included

Hi all,

Man, I have tested this problem in every way and with every browser and configuration I can think of - and no luck. I could really use some guidance on this if possible. Any help would be very much appreciated.

My problem is with including the xajax_core.js file in my application. I'm working in a fairly complex CodeIgniter framework, but in order to try to isolate this problem I created a simple test page and am still getting:

Error: the xajax Javascript component could not be included. Perhaps the URL is incorrect?
URL: res/xajax_js/xajax_core.js

This happens if I set the $xajax->configure('javascript URI', 'res/') variable to the absolute path, the relative path, the http path, etc. I've checked permissions, moved the folder and even tested that I could open the file in a browser. No luck.

I'm running Apache 2.2.15 and PHP 5.3.3 in case that might matter.

Here is my test page (taken from another post in this forum which seemed to deal with the same issue):

<?php
/**
* 2012-01-19 Ed
* Simple xajax demo page
*
*/

include 'system/libraries/xajax/xajax_core/xajax.php';
$xajax = new xajax();
$xajax->configure('javascript URI', 'res/');

function favoris($user,$fav,$add)
{
    //let's say there's a sql request here. OK
    if($add) //if we add
    {
        $text='Added to your favorites.';
    }
    else
    {
        $text='Removed from your favorites.';
    }    
    
    $objResponse = new xajaxResponse();
    $objResponse->assign('favoris2', 'innerHTML', $text); //So we put $text in <div id="favoris"></div> right?
   
    return $objResponse;
}

$xajax->register(XAJAX_FUNCTION,'favoris');
$xajax->processRequest();
$xajaxjs = $xajax->getJavascript(); //Loads the js into the variable
?>

<!DOCTYPE html>
<html>
<head>
<title>Xajax Sample</title>
<?php echo $xajaxjs; ?>
</head>
<body>
<div id="favoris">
<button onclick='xajax_favoris(1,"0,9,5,4,27",1);'>Add Favorite</button>
<button onclick='xajax_favoris(1,"0,9,5,4,27",0);'>Remove Favorite</button>
</div>
<div id="favoris2"></div>
</body>
</html>

The script does find the file 'xajax.php' but then fails to located the xajax_js folder. 

Please help!

Luke

Re: Error: the xajax Javascript component could not be included

Hi Luke,

I am using CI lately and had the same problem with the xajax js files. If I recall, it was a permission or direct access denied problem on the folder.

Another thing you might try is setting the uri 'res/xajax/'

I'll see if i can recall my solution and get back...

Ed

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

Re: Error: the xajax Javascript component could not be included

edrobinson wrote:

Hi Luke,

I am using CI lately and had the same problem with the xajax js files. If I recall, it was a permission or direct access denied problem on the folder.

Another thing you might try is setting the uri 'res/xajax/'

I'll see if i can recall my solution and get back...

Ed

Thanks for the thoughts, Ed. I'll clear my mind and try some fresh approaches like rechecking permissions and direct access blocks. So frustrating when it's the 'little things' like this that slow you down for hours or even days....... sad

Re: Error: the xajax Javascript component could not be included

I autoload xajax and set it up in MY_Controller:

$this->xajax->configure('javascript URI', base_url().'application/libraries/xajax/');

Perhaps using base_url() in the javascript URL makes the difference.

In my autoload.php i use this to load xajax:

$autoload['libraries'] = array('xajax/xajax_core/xajax','parser','database');

I changed the name of xajax.inc.php to xajax.php just to keep things consistant.

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

Re: Error: the xajax Javascript component could not be included

edrobinson wrote:

I autoload xajax and set it up in MY_Controller:

$this->xajax->configure('javascript URI', base_url().'application/libraries/xajax/');

Perhaps using base_url() in the javascript URL makes the difference.

In my autoload.php i use this to load xajax:

$autoload['libraries'] = array('xajax/xajax_core/xajax','parser','database');

I changed the name of xajax.inc.php to xajax.php just to keep things consistant.

Thanks, Ed. That looks similar to some things I've tried, but I'll go back and review those areas. What version of CI are you using? I ask because you have you xajax library in 'application' rather than 'system' - which is possibly a clue to my issue.

Also, do you happen to know what script is generating this error (where the error message lives)? I can't locate that in my code and that's also confusing.

Luke

Re: Error: the xajax Javascript component could not be included

I am using the 2.1.2 version. I believe you are supposed to put your libraries in the application/libraries folder.

Looking at a clean install I notice there is an index.php in the app libraries folder and I have removed it from my working copies. Putting it back produces the problem you are experiencing. Makes sense as xajax is trying to read from the folder to get the xajax js. Try it out...

P.S. Also had to remove index.php and htaccess from the application folder...

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

Re: Error: the xajax Javascript component could not be included

edrobinson wrote:

I am using the 2.1.2 version. I believe you are supposed to put your libraries in the application/libraries folder.

Looking at a clean install I notice there is an index.php in the app libraries folder and I have removed it from my working copies. Putting it back produces the problem you are experiencing. Makes sense as xajax is trying to read from the folder to get the xajax js. Try it out...

P.S. Also had to remove index.php and htaccess from the application folder...

I've tried making these changes and removing any htaccess and index files with no changes. It's odd that I can open the file in my browser, but I get this error from within xajax.

Do you know where this error is being generated from? I mean, at which point in the code and in what file is this coming from? If I could locate that I could probably trace the problem back.

Thanks!

Re: Error: the xajax Javascript component could not be included

I think I've got the correct script and function which is triggering this error. Just wanted to confirm, if possible, so I can run more tests to figure out what I'm doing wrong.

xajaxPluginManager.inc.php function generateClientScript()

If this function can't locate the /xajax_js/xajax_core.js file it throws this error. Correct?

Re: Error: the xajax Javascript component could not be included

Not sure. I'll look into it...

I find it in xajax\xajax_core\plugin_layer\xajaxDefaultIncludePlugin.inc.php and

xajax\unit_test\xajaxAIO.inc.php

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

10 (edited by lsalsich 2012-10-08 8:17:55 PM)

Re: Error: the xajax Javascript component could not be included

edrobinson wrote:

Not sure. I'll look into it...

I find it in xajax\xajax_core\plugin_layer\xajaxDefaultIncludePlugin.inc.php and

xajax\unit_test\xajaxAIO.inc.php

I'm using Xajax 0.6 Beta 1. Are you using 0.5?

Sorry - maybe this should be moved the 'Beta' forum? This seems directly related to the changes in 0.6 from what I can tell.

Re: Error: the xajax Javascript component could not be included

I have 0.5 on my production site and change back and forth in my development environment.

I scanned my copy of 0.6 B1 and found the message only in this file:

xajax0.6beta\xajax_core\plugin_layer\xajaxDefaultIncludePlugin.inc.php

I heven't traced it though to see where i gets called from.

Just tried my production code using 0.6beta with - hate to say this but - no problems

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

12 (edited by lsalsich 2012-10-09 1:40:47 PM)

Re: Error: the xajax Javascript component could not be included

edrobinson wrote:

Just tried my production code using 0.6beta with - hate to say this but - no problems

That's good news, Ed. Thanks a ton for continued feedback. I think that after weeks of work I realized that I downloaded the 0.6 code from GitHub - originally thinking 'if it works, I'll go with the latest code', but then I forgot that I did this as I became engrossed in the code. But, I would not have made this connection if you hadn't pointed out where your code was being called because it was very different from mine!

It turns out that this area of the code is very different in the code in GitHub then in the Beta release. Being a developer, this makes sense, of course. Inf act,I don't think this area of the code in GitHub works and I can probably tell them why after my days of going over it. Here's me laughing at myself. smile

I switched out the 'approved' 0.6 Beta release and it works perfectly. Geez........

Re: Error: the xajax Javascript component could not be included

Yeah!

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