javascript - How To use js variable into another file -


i have javascript variable has value on-change. want use variable in file calculation.

for example have variable in index.php follow:

    $(function() {        $("#sel").on("change", function() {        var vall = $(this).find('option:selected').attr('value')        alert(vall);     });    }); 

and in file calculate.php have code , want use "vall" variable multiple "$total variable"

public function getgrandtotal(){     $quote = mage::getmodel('checkout/session')->getquote();     $total = $quote->getgrandtotal();     $gt =  $total *  var vall ; // "vall" variable multiply total      return mage::helper('checkout')->formatprice($gt); } 

that should done ajax like:

$("#sel").on("change", function() {    var vall = $(this).val();    $.ajax({         type:'post',        url : "url call",        data:{val : vall}, // send vall here val in backend.        datatype:'text', // other values json, script, html etc.        success:function(data){           console.log(data);  // <----get response backend if echoed.        }    }); }); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -