在Joomla的全局配置中,当SEF设置为ON时,Ajax URL无法正常工作

时间:2013-11-13 13:37:09

标签: php jquery joomla joomla2.5 joomla-sef-urls

我在我的文件中通过JQuery.post方法传递数据。当Joomla 2.5中的服务器上的“搜索引擎友好URL”和“使用URL重写”关闭时,它的工作成功,但当两个设置都为ON时,JQuery.post的网址会发生变化而无法正常工作。

jQuery.post('index.php?option=com_requests&controller=dashboard&task=messagesendtocook&format=raw&tmpl=component', { 
    replymessage:replymessage,fromid:fromido,msdid:msdido,refid:refido}, function(data) {
        alert(data);
        setTimeout( 'reload_parent_window();', 2000 );  
        window.parent.SqueezeBox.close();
}); 

SEO设置为关闭时的网址参数

index.php?option=com_requests&controller=dashboard&task=messagesendtocook

成功运行。

SEO设置为开启时的网址参数

index.php/component/requests/index.php?option=com_requests&controller=dashboard&task=messagesendtocook

没有运行。

2 个答案:

答案 0 :(得分:3)

Juri::root()与网址一起使用。 所以代码是 -

jQuery.post('<?php echo Juri::root()?>index.php?option=com_requests&controller=dashboard&task=messagesendtocook&format=raw&tmpl=component', { 
    replymessage:replymessage,fromid:fromido,msdid:msdido,refid:refido}, function(data) {
        alert(data);
        setTimeout( 'reload_parent_window();', 2000 );  
        window.parent.SqueezeBox.close();
}); 

答案 1 :(得分:0)

我发现只需在网址中添加一个前导/就可以了,将其转换为:

'/index.php?option=com_requests&controller=dashboard&task=messagesendtocook&format=raw&tmpl=component'