I have this JavaScript code
var list = "";
$.each(data.result.products, function (i, item) {
    var prices = item.salePrice;
    list = list +
        '<h3>' + item.productTitle + '</h3>' +
        '<h4>' +  item.salePrice + ' </h4>' +
        '<?php $price = "" ?>' +
        ;
})
I want item.salePrice in PHP variable <?php $price = "" ?>. What will be the best solution to assign price value to PHP variable.
 
     
    