Topic: Loading $xajax->printJavascript() on a External Javascript


After reading different post I finally have put them all together to have a working way to load the xajax to a external javascript file.

function getCorrectURI()
$split = explode("/",$_SERVER['SCRIPT_NAME']);
$count = count($split) - 1;
return rtrim($split[$count]," ");

// xajax
$xajax = new xajax();
$xajax->configure('scriptLoadTimeout', 0); // ADD THIS FOR DEFER FILE
$xajax->configure('requestURI', getCorrectURI()); // ADD THIS FOR DEFER FILE
$xajax->configure('deferScriptGeneration', true); // ADD THIS FOR DEFER FILE

Add the sections that show ' // add this to defer file ';  PLUS YOU NEED TO ADD THE getCorrectURI() Function

Final result will show

<script type='text/javascript' src='index.php?xjxGenerateJavascript=b8d8998efd0128722bdbbb01ee60d74c' charset='UTF-8'></script>

The reason I created the getCorrectURI() is because I use dynamic pages that are in a folder "" and not " .  This way it will discover the file name even if the url is different.

Hope this helps.  If you have an idea to make it better let me know and I will update it.

Re: Loading $xajax->printJavascript() on a External Javascript

Our posts crossed - yours is better!

Re: Loading $xajax->printJavascript() on a External Javascript

This is a wonderful opinion. The things mentioned are unanimous and needs to be appreciated by everyone
Motel Reservations

Re: Loading $xajax->printJavascript() on a External Javascript

I was looking for this. Thank you, Carlitos smile

Re: Loading $xajax->printJavascript() on a External Javascript


I think "print($chemin_xajax);" might be your problem.

It will happen every time the page loads and will confuse the xajax code in the browser.

If you put it after $xajax->processrequest() it will only happen on the initial page load.

Hope this helps... smile


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

Re: Loading $xajax->printJavascript() on a External Javascript

If we can't fix the problem, do you know another way for the printJavascript() problem and URL Rewriting ?

Re: Loading $xajax->printJavascript() on a External Javascript

Hi everyone,

(I deleted my previous message for security)

I found another way to fix the problem. Because I think this methode doesn't function with Ajax0,5 standart.
If you are using URL REWRITING and you want to fix javascript error you can use this Function.

function chemin()  // add this function to know all sub folder of your ROOT
        $a=$_SERVER['REQUEST_URI'];  // this is the magic code If you are using MOD REWRITING
        for ($i=0;$i<$f;$i++)
        return $g;
$chemin = chemin();  // Call your function

// xajax
$xajax = new xajax(); //On initialise l'objet xajax
$xajax->configure('javascript URI', $chemin."xajax/");  // include  your path: $chemin 

I hope it will Help You!