Note that there are some explanatory texts on larger screens.

plurals
  1. POMultilingual i18n library interfering with ajax calls
    primarykey
    data
    text
    <p>I'm using Codeigniter with the i18n library to build a multilingual website. I followed <a href="http://codeigniter.com/wiki/CodeIgniter_2.1_internationalization_i18n" rel="nofollow">this guide</a> and it works fine.</p> <p>The problem there is, apparently, in pages where I have to ajax calls, in jQuery, throug <code>$.getJson</code>.</p> <pre><code>console.log('1'); return $.getJSON("photos/change_product", json_data, function(data) { console.log('2'); </code></pre> <p>In this piece of code, for example, in the console it just prints "1". Using Firebug I see that the urls for the get calls look like these:</p> <pre><code>GET http://localhost/website/photos/change_product?product_id=1 GET http://localhost/website/en/photos/change_product </code></pre> <p>I tried disabling the library and the page worked as it should, so I'm pretty sure there's a conflict with this library, but I don't really know where to start looking. Any suggestion?</p> <p>EDIT: I partially solved this. At least, I've found a workaround. It seems like I should use the function <code>site_url()</code> inside the javascript, so that it creates the correct link, as explained in the library's wiki. Obviously I cannot use a php function inside a javascript file so, in a <code>view</code>, before loading the script, I put this:</p> <pre><code>&lt;script type="text/javascript"&gt; var siteurl = "&lt;?=dirname(site_url('a'))?&gt;"; </code></pre> <p>And now I have the path to prefix wherever I need it. It's just a bit ugly. Do you think is there any better way to do this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload