title: How to run PHP funcion in an jQuery .get() method?
body: <p>I want to use PHP function,like the echo and $_GET, in my jQuery.get() method. However, the browser always running error.</p>
  <p>test.js file:</p>
  <pre><code>  function checkoutUpdateQty(productid, price, qty) {
      $.get(&quot;https://example.com/wp-content/themes/somethemename/functions/ajax/updatecart.php&quot;, { sid: &quot;&lt;?php echo $_GET['sid']; ?&gt;&quot;, action: 'changeqty', id: productid, price: price, qty: qty }, function(data) {
  
          //update price
          newprice = price*qty;
          newprice = newprice.toFixed(2);
          
          //send to dom
          $('#totalprice_'+productid).text(&quot;$&quot;+newprice);
         
          //update summary total
          $.get(&quot;https://example.com/wp-content/themes/somethemename/functions/ajax/updatecart.php&quot;, { sid: &quot;&lt;?php echo $_GET['sid']; ?&gt;&quot;, action: 'gettotal' }, function(data) {
              $('#summary_carttotal').text(&quot;&quot;+data);
          } );
      
      } );
  </code></pre>
  <p>}</p>
  <p>However, the browser developer tool shows the HTTP request is:</p>
  <p>&quot;https://example.com/wp-content/themes/somethemename/functions/ajax/updatecart.php?sid=%3C%3Fphp%20echo%20%24_GET%5B%27sid%27%5D%3B%20%3F%3E&amp;action=addproduct&amp;id=41&amp;qty=1&amp;ship=0&amp;c1=&amp;c2=&amp;c3=0&amp;c4=&amp;c5=&amp;c6=0&amp;c7=&quot;</p>
  <p>, which means the PHP syntax (function echo() and variable $_GET[]) is treated as String but not correctly running.</p>
  <p>How can I solve the problem? Many Thanks!</p>