Hi!
I had a lot of troubles getting AJAX working on my local server, but at least it works now (with one small flaw). As I use a lost of external scripts, I created a configuration parameter for my module called : $modpath
$basepath = $modx->config["base_path"];
$modpath = isset($modpath) ? $basepath.$modpath : $basepath.'assets/modules/mymodule';
As i’m using the WinXP distribution of uniserver to develop my application, $modpath now has the value : "W:/www/assets/modules/mymodule".
This is fine for PHP, but if I use it this way :
<script type="text/javascript">
var modpath = '<?php echo $modpath; ?>';
</script>
so that in my AJAX code I can call my handlers that way :
/********************************************** HERE ***************/
var url = modpath + '/ajax.handler.php';
/********************************************************************/
var params = 'catname=' + $F('txtNewCategory');
alert(url);
var request = new Ajax.Request(
url,
{
method: 'get',
parameters: params,
asynchronous:true,
onComplete: function(r) {
alert(r.responseText);
}
});
}
it try to call the url "W:/www/assets/modules/mymodule" that cannot exist. how could I set a base url easily for my scripts??
thanks a lot in advance,
Blaise