简体   繁体   English

Joomla中的POST 404错误(找不到组件)

[英]POST 404 Error (Component not found) in Joomla

I am running some custom php file that contains some javascript code within a Joomla website through an extension called sourcerer. 我正在运行一些自定义php文件,该文件通过名为sourcerer的扩展名在Joomla网站内包含一些javascript代码。 Everything works as expected from the php side of things however I am experiencing an issue with a call to another php file made from within a javascript. 一切都按预期从php方面进行,但是我遇到了一个从JavaScript内调用另一个php文件的问题。 Here is the javascript code in question and on the second line is the "suburb.php" file that is called from within this code that is causing the issue. 这是有问题的javascript代码,第二行是导致该问题的代码中的“ suburb.php”文件。

$.ajax({
 url : 'suburb.php',
 dataType: "json", 
 method: 'post',
 data: {
     name_startsWith: request.term,
     type: 'suburb_table',
     row_num : 1
 },
 success: function( data ) {
     response( $.map( data, function( item ) {
         var code = item.split("|");
         return {
             label: code[0],
             value: code[0],
             data : item
         }
     }));
 }
});

The problem I am having is that even though the originating php file that contains this javascript is in the same directory as the suburb.php file, Joomla seems to change the URL call to "localhost/index.php/menu_alias/suburb.php" and this causes a POST error 404 (Component non found). 我所遇到的问题是,即使包含此javascript的原始php文件位于与bourne.php文件位于同一目录中,Joomla似乎也将URL调用更改为“ localhost / index.php / menu_alias / suburb.php”并导致POST错误404(找不到组件)。

I have tried using many variation of the url path in that second line of the code, but all have failed. 我已经尝试在代码的第二行中使用很多形式的url路径,但是都失败了。 Can somebody tell me what my url path should look like for this to work? 有人可以告诉我我的网址路径应该是什么样的吗?

Thank you, Adri 谢谢阿德里

Use an absolute URL instead of of just "suburb.php" so it should be something like: http://www.[joomlasite].com/suburb.php 使用绝对URL而不是“ suburb.php”,因此它应该类似于: http:// www。[joomlasite] .com / suburb.php

As for the localhost, then I would say you likely have the $live_site set to "localhost" in your configuration.php - make sure you set the $live_site to empty. 至于本地主机,那么我想说,您可能在$live_site中将$live_site设置为“ localhost”-确保将$live_site设置为空。 If that's not the case, then search your database for any occurrence of localhost. 如果不是这种情况,请在数据库中搜索是否存在本地主机。

Thank you for your feedback. 感谢您的反馈意见。 I tried with absolute urls with the standard format, but it gave some sort of restricted error. 我尝试使用标准格式的绝对URL,但是它提供了一些受限错误。 Somebody then suggested this option, which has worked and solved my problem 然后有人提出了这个选项,它可以解决我的问题

url : "<?php echo Juri::base(); ?>directory/etc/suburb.php",

Thanks, Adri 谢谢阿德里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM