【发布时间】:2016-02-06 05:00:30
【问题描述】:
我想加载简单的 codeignitier 控制器,但没有成功我得到 404 错误。
看起来 jquery 加载不支持漂亮/清晰的 url?有可能吗?如何实现?
当我尝试使用相同的代码加载一些文件时,它工作得很好,但是当我尝试加载 codeignitier 控制器功能时,我在控制台中得到 404。
<script type="text/javascript">
$(document).ready(function () {
$("#season").load('https://www.example.co/index.php/system/example');
//i already tried without 'index.php'
});
</script>
当我使用一些简单的文件检查加载功能是否正常工作时,它工作正常:
<script type="text/javascript">
$(document).ready(function () {
$("#season").load('https://www.example.co/test.php');
});
</script>
和控制器:
public function example(){
echo "EXAMPLE";
}
此链接存在且不是404(当然没有例子):
【问题讨论】:
-
你检查过你的路线
-
@Snm 路由正确。我也尝试使用 base_url 函数,结果是一样的。是否可以通过加载功能加载漂亮的链接?我知道“丑陋”的网址有效,但如何使用漂亮的链接?
-
你能告诉我你是如何使用 htaccess 和路由的吗
-
@Snm 我在 .htaccess 中重写 index.php。 / => public_html => application => index.php /controllers => System.php / => public_html => application => index.php /views => test.php 从 test.php 我调用 System.php 函数示例( )。
标签: php jquery ajax codeigniter