On Mar 26, 1:11 am, Code Daemon <ryan.det...@gmail.com> wrote:
> I am using codeigniter and it forms urls like this:
>
> http://mydomain/index.php/system/edit_js
>
> I'm trying to call $.getScript by going:
>
> $.getScript( ") but I get a
> 404 not found error. I pasted the url in my webbrowser and it works
> just fine.
>
> Is there any way to make this work?

I'm having the same problem, and it looks like both frameworks (CI and
jQuery) are partially responsible.

If you look in firebug in the net panel or at the generated source of
your page you'll see something like "http://mydomain/index.php/system/
edit_js?_=1240583133908", the ?_NNN is appended by jQuery's ajax
method and looks like a cache buster. Code igniter, however, doesn't
like to use query strings and will return a 404 on this.

To disable this you could make you own getScript function that passes
parameters to jQuery's ajax function:

    // Create a modified getScript method to ignore the cache buster
    function getScript(url, callback) {
        return jQuery.ajax({
            type: "GET",
            url: url,
            data: null,
            success: callback,
            dataType: "script",
            cache : true
        });
    }

This will stop it from putting that query string in there, but certain
browsers (guess!) will cache the response indefinitely. This works
fine for data that doesn't change much, but could be a problem for
something that is frequently updated.

You other option might be to turn on query strings in CI, but that's
an all or nothing option (that's my least favorite thing about CI,
besides the language it's witten in :))

Hope that helps.

Nathan

Reply via email to