sarfaraz.r1406 Posted April 13, 2014 Share Posted April 13, 2014 (edited) I am creating a variable in my tpl file. var dlot=document.getElementById("select").value; Now I want to access this variable in PaymentModule.php. How can I do that? I have a minimum knowledge of ajax. Please help. Edited April 13, 2014 by sarfaraz.r1406 (see edit history) Link to comment Share on other sites More sharing options...
icstra Posted April 13, 2014 Share Posted April 13, 2014 Hi, I think that .php populates data in .tpl and not the opposite. .tpl files are templates used for html building. Link to comment Share on other sites More sharing options...
sarfaraz.r1406 Posted April 13, 2014 Author Share Posted April 13, 2014 I agree. But I am getting a variablr in javascript oh tpl file. I want to use it in PaymentModule.php file. Please help Link to comment Share on other sites More sharing options...
PascalVG Posted April 13, 2014 Share Posted April 13, 2014 Maybe this helps http://stackoverflow.com/questions/10529964/sending-javascript-variable-from-view-to-controller-in-codeignitor (2 scenarios described here, one for if you have a submit form on your tpl page already, and one without) Hope this helps. My 2 cents, pascal. Link to comment Share on other sites More sharing options...
vekia Posted April 13, 2014 Share Posted April 13, 2014 you have to pass value of this variable with ajax request. there is no other way to pass it to php file from js/tpl 1 Link to comment Share on other sites More sharing options...
sarfaraz.r1406 Posted April 14, 2014 Author Share Posted April 14, 2014 (edited) This is how I am writing my ajax request. $.ajax({ url: "C:\xampp\htdocs\prestashop1\prestashop\classes\PaymentModule.php", cache: false, data : { varNew : '1', }, success : function(res,textStatus,jqXHR) { } });I want to receive this var "varNew" in PaymentModule.php. Please tell me how to write the receiving statement because the syntax provided in that link isn't working. I am hooking this module on the 4th step(carrier) of the payment page. So I dont think I am submitting any form there. Thank you. Regards Sarfaraz Edited April 14, 2014 by sarfaraz.r1406 (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted April 14, 2014 Share Posted April 14, 2014 i think that this: url: "C:\xampp\htdocs\prestashop1\prestashop\classes\PaymentModule.php", is wrong url you can't call PaymentModule.php file because it's a class, not static script... take a look what kind of code uses homeslider (in homeslider.php file) to call ajax request - it's a very good example Link to comment Share on other sites More sharing options...
sarfaraz.r1406 Posted April 15, 2014 Author Share Posted April 15, 2014 Hi vekia, Thank you for your answer. I would appreciate if you help me with my issue. Actually I want to write this variable newVar into my database in ps_order along with the order_id. So that I an keep a track for which order what is the value of my variable. The writing into the database is initiating in PaymentModule.php. So I need to access this variable from that class. Kindly suggest a way to do this. Regards Sarfaraz Link to comment Share on other sites More sharing options...
sarfaraz.r1406 Posted April 18, 2014 Author Share Posted April 18, 2014 @Vekia... can u plz help me with this issue? Link to comment Share on other sites More sharing options...
vekia Posted April 18, 2014 Share Posted April 18, 2014 you have to do this in controller, not in class you mentioned. you extended your table to store additional information ? Link to comment Share on other sites More sharing options...
sarfaraz.r1406 Posted April 18, 2014 Author Share Posted April 18, 2014 Yes I have added a column in PS_order. Which controller I'll have to use for this? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now