dongre1907 2013-08-27 13:29
浏览 45

使用jQuery Mobile的Codeigniter有时会返回错误的base_url()

Good day, fellow coders!

I am currently working on a mobile version of a website. We are initially using Codeigniter as framework, but as for the mobile version, we are asked also to use a bought Mobile Template package that uses jQuery Mobile.

PROBLEM:

By going to other pages (clicking on links via anchor tags, buttons, ajax redirect, etc) errors RANDOMLY occur on the following:

  • broken links of images
  • broken href links on anchor tags
  • going to a wrong controller (page not found)

I have noticed that even if I add in on every link it goes, the link changes to the current full URL..

EXAMPLE:

I am in

http://localhost/m.mysite/dashboard

and from that page I am in, if I click on

<a href="<?php echo base_url();?>home/login">

the URL it will go to will be

http://localhost/m.mysite/dashboardhome/login <!-- ERROR -->

but if I refresh that page again, I will successfully see no broken links

http://localhost/m.mysite/home/login <!-- CORRECT -->

If I refresh the site, errors will be gone. Is this because jQuery mobile only do haschange and not refreshing each page?

How come it's like this even if I added <?php echo base_url(); ?>

In the application/config/config.php, I have also made sure that I did not miss to indicate my base url as http://localhost/m.mysite/

  • 写回答

1条回答 默认 最新

  • drdu53813 2013-08-27 13:40
    关注

    Try site_url() instead of base_url(), maybe it would help. There shouldn't be anything wrong with base_url(), but still.

    Another thing - could it be something additional in your .htaccess files that makes the redirect? You could check the original link from /dashboard, just hover your mouse on the link and look what browser status bar shows. Or go to View Source.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!