【问题标题】:CodeIgniter ajax postCodeIgniter ajax 帖子
【发布时间】:2010-09-09 01:39:10
【问题描述】:
 function new_review(){
    $.post('restaurant_profile/get_dg_new_restaurant_review', {}, function callback(response) {
          alert(response);
    }
 }

您好,我有一个将 jQuery ajax 发布到控制器函数的函数。该函数使用 PHP echo 函数输出一个简单的字符串。

如果在初始页面加载中控制器名称之后没有任何 URI 段,则该函数可以正常工作。

ex: mysite.com/index.php/test_controller/

例如,如果页面加载了索引函数并且 URI 段包含索引函数

ex: mysite.com/index.php/test_controller/index

控制器的响应是索引函数输出的所有字符串。 这是整个页面的 HTML。我只想要来自et_dg_new_restaurant_review 函数的文本

有谁知道如何解决这个问题?

【问题讨论】:

    标签: jquery ajax codeigniter url-routing


    【解决方案1】:

    其实我想通了。 帖子网址必须是完整网址

    http://www.mystite.com/index.php/restaurant_profile/get_dg_new_restaurant_review

    【讨论】:

      【解决方案2】:

      其实不需要完整的url,你可以试试这个:

      "/index.php/restaurant_profile/get_dg_new_restaurant_review"
      

      如果你已经完成了路由重写(隐藏/删除 index.php 的需要),你可以使用这个:

      "/restaurant_profile/get_dg_new_restaurant_review"
      

      请记住以“/”开头您的网址

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-01-04
        • 1970-01-01
        • 1970-01-01
        • 2016-05-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多