I'm trying to send a Javascript variable to a php file. Everething is ok in the JS side, I receive a msg that data is sent, but in the php side nothing happen, here is my JS code:
$(".add-to-cart").click(function(event){
event.preventDefault();
$.ajax({
type: "POST",// see also here
url: 'c.php',// and this path will be proper
data: {
source1: "some text",
source2: "some text 2"}
}).done(function( msg )
{
alert( "Data Saved: " + msg );// see alert is come or not
});
});
and the php code:
<?php
$src1= $_POST['source1'];
$src2= $_POST['source2'];
echo $src1;
echo $src2;
?>