prestashop_newuser Posted September 7, 2013 Share Posted September 7, 2013 Hi, I am doing a small module in prestashop. As per the requirment of the module I need ajax. For ajaxI used jQuery ajax.So to do that I made my code something like this function selectCountry() { var state = $('#country').val(); //console.log(state); $.ajax({ type: "GET", url: "http://localhost/WebSites/Prestashop/modules/mymodule/selectstate.php", cache: false, data: { sta : state }, success: function(html) { $(".city").html(html); } }); } Now here I have a query. You can see in url I am doing path in hard coded (url: "http://localhost/WebSites/Prestashop/modules/mymodule/selectstate.php"). Here its fine but what about the url. As it is hard-coded it will work only on my system. I want to know how to make it a dynamic path. So that if someone will install the module he will get the module working. Any help and suggestions will be really appreciable. Link to comment Share on other sites More sharing options...
NemoPS Posted September 7, 2013 Share Posted September 7, 2013 You can use ther baseDir variable, which is assigned in the header.tpl file, and is accessible on all embedded javascript. It points to the main site url. Therefore you can use it like this: url: baseDir + "/modules/mymodule/selectstate.php", 1 Link to comment Share on other sites More sharing options...
prestashop_newuser Posted September 7, 2013 Author Share Posted September 7, 2013 You can use ther baseDir variable, which is assigned in the header.tpl file, and is accessible on all embedded javascript. It points to the main site url. Therefore you can use it like this: url: baseDir + "/modules/mymodule/selectstate.php", so shall I assign baseDir in my .tpl file or it is by default assigned in prestashop? Link to comment Share on other sites More sharing options...
NemoPS Posted September 7, 2013 Share Posted September 7, 2013 It's already assigned Link to comment Share on other sites More sharing options...
prestashop_newuser Posted September 7, 2013 Author Share Posted September 7, 2013 It's already assigned Thanks .. it worked like a charm... Link to comment Share on other sites More sharing options...
Recommended Posts