I have a function.I want Data passing through ajax is store in php variable.I tried below code but not work please some one help me.
function moreinfo(prodid,catid,price,type,catname) {
url2="<?php echo $this- >getUrl('compatibility/compatiblelist/moredetails'); ?>";
$j.ajax({
url:url2,
type: 'POST',
data: {"prodid": prodid},
success: function(response) {alert(console.log(response));}
});
<?php
$ms = $_POST["prodid"];
echo $ms;
?>
}
<?php ?>
tags only work when file name must be .php. may you are using that process in .js file kindly change the ext
consider separating the file, .js and .php then you can include .js file
function moreinfo(prodid,catid,price,type,catname) {
url2="something.php";
$.ajax({
url:url2,
async:false,
type:'POST',
data: {prodid: prodid},
dataType:'html',
success: function(response) {alert(console.log(response));}
});
}
In your something.php
<?php
$ms = $_POST["prodid"];
echo $ms;
?>