Put or handle base_url in file .js.. [solved] |
[eluser]tnathos[/eluser]
Hi.. in my app i use file .js for handled events ajax.. whit this events use in severals i ut this funcions in external .js for include in each view.. So all works fine.. but now i have 2 enviroments for development + production.. and if i need test the app i need chagen always the route in the calls ajax.. i have this for example.. Code: function borrar_fav_oferta(id_proceso) so i need chagne always "http://localhost:8888/misyte/" for the domain.. in all files!! i try del http://localhost:8888/misyte/ and works but only when i have a location.href.. but when i call the ajax.. in the param url:.. dont works.. any can help me? hiw i can del "http://localhost:8888/misyte/" forn the js for all calls? thanks
[eluser]InsiteFX[/eluser]
Try this in your code. Code: var base_url = base_url(); Enjoy InsiteFX
[eluser]Kamarg[/eluser]
You can also use the base tag in your html head tag so that you don't need the base url in your .js files.
[eluser]tnathos[/eluser]
ok solved.. if any have te problem similar.. if use a path relative for call the ajax have a problem because whit use the same .sj in others views and model the path relative fail.. so the solution its create in the head a global variable for js and this variable set the php variable.. and in the files .js using this var. |
Welcome Guest, Not a member yet? Register Sign In |