Query string enabled and possible bug with current_url |
[eluser]Jelenik[/eluser]
Hi all, i had to enable query strings because i am using new version of jquery for ajax calls which return data in json. Jquery allways appends url of request with ?callback=..... so all of my ajax functions in controller were unaccessible until i enabled query strings. But now when i use current_url - it adds question mark before uri segments. For example: real url adress in browser: "http://localhost/test/something" adress shown via current_url(): "http://localhost/?/test/something" When i turning on that query string support i didnt expected that it will affect some functions - so i dont know if this behaviour is OK, or it is a bug?
[eluser]Atharva[/eluser]
Quote:Jquery allways appends url of request with ?callback=. Not sure what you meant by this, but you can simply use Code: var url = "<?=base_url()?>index.php/controller/function/";
[eluser]toopay[/eluser]
[quote author="Jelenik" date="1303108554"]i had to enable query strings because i am using new version of jquery for ajax calls which return data in json. Jquery allways appends url of request with ?callback=..... so all of my ajax functions in controller were unaccessible until i enabled query strings.[/quote] And why you activate query strings, if you just need to fetch $_GET var? Actually you could get the same result, by doing something like this... Code: // In your controller
[eluser]Jelenik[/eluser]
[quote author="Atharva" date="1303126970"] Quote:Jquery allways appends url of request with ?callback=. Not sure what you meant by this, but you can simply use Code: var url = "<?=base_url()?>index.php/controller/function/"; Yes Artharva - i know how send post call I am saying that with your example jquery will add to var url ?callback=Jquery.... if you want or dont want. You can read more about that here: http://www.victorocastro.com/2011/02/26/...t-the-219/ [quote author="toopay" date="1303127387"] And why you activate query strings, if you just need to fetch $_GET var? Actually you could get the same result, by doing something like this... Code: // In your controller Thanks toopay - i didnt know that i can access get variables without enabling query strings. So i have disabled them and i had to set $config['uri_protocol'] to PATH_INFO - when i had AUTO - all ajax calls with ?callback=Jquery.... on the end of url were served from main controller and not from right controller. Ok, so i figure it out thanks you guys to have query string disabled. But is that behaviour of current_url right when query string is enabled?
[eluser]stormbytes[/eluser]
I came across this problem today. So is CI simply incompatible with jQuery's native get/post methods? $.get/.post, because of query strings? It'd be a lot easier to be able to simply pass an argument to a controller method without all this hoopla.
[eluser]Jelenik[/eluser]
You need only to change this: Code: $config['uri_protocol'] = 'AUTO' to this Code: $config['uri_protocol'] = 'PATH_INFO'; You don't need to enable query strings. You can get variables from jquery ajax calls via post, or get: Code: $something = $this->input->post('something'); Hope it helps - its working for me this way. |
Welcome Guest, Not a member yet? Register Sign In |