JQuery不会加载明确的URL?

时间:2015-11-05 11:18:34

标签: php jquery ajax codeigniter

我想加载简单的codeignitier控制器,但没有成功我得到 404 错误。

看起来jquery加载不支持漂亮/清除网址?它有可能吗?如何?

当我尝试使用相同的代码加载某些文件时,它可以正常工作,但是当我尝试加载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(当然没有示例):

  

https://www.example.co/index.php/system/example

enter image description here

2 个答案:

答案 0 :(得分:0)

尝试将其传递为

onCreate -> onResume

答案 1 :(得分:0)

我通过添加'?'来解决它在index.php之前。 所以这就是结果:

<script type="text/javascript">
    var PI = {

    onReady: function() {
        $.ajax({ 
        type: 'GET', 
        url: '/index.php?/system/getseasons/SC0', 
        success: function (response) { 
            alert('success');
            $("#season").html(response);
        },
        error: function(xhr, textStatus, error){
              console.log(xhr.statusText);
              console.log(textStatus);
              console.log(error);
        }


        })
    },

    };

    $( document ).ready( PI.onReady );

</script>
相关问题