title: How to assign vat value calling from php to Javascript for my function in easy way?
body: <p>I want to assign a value ($productVatValue) taking from php to javascript using JSON, how I can achieve that for my code?</p>
  <p>here is the code on Javascript</p>
  <pre><code>var vat = (Number($(&quot;#subTotal&quot;).val())/100) * $productVatValue;
      vat = vat.toFixed(2);
      $(&quot;#vat&quot;).val(vat);
      $(&quot;#vatValue&quot;).val(vat);
  </code></pre>
  <p>and here is the fetchOrderVat.php that calls the vat value</p>
  <pre><code>&lt;?php   
  
  require_once 'core.php';
  
   
  $sql = &quot;SELECT vat FROM usercompany WHERE id = 1&quot;;
  $result = $connect-&gt;query($sql);
  
  if($result-&gt;num_rows &gt; 0) { 
   $row = $result-&gt;fetch_array();
  } // if num_rows
  
  $connect-&gt;close();
  
  echo json_encode($row);
  </code></pre>