Reputation: 187
Soo I do an ajax load to load a php file in my website. however I need to pass the variable "needednumber" to this php file. How would I do this? And how would I open it in the php file?
<script>
var arr = <?php echo json_encode($arr) ?>;
function deletefunction(pass)
{
var needednumber = arr[pass];
//$description = $_POST['needednumber'];
$('#ajax').load('<?php echo get_template_directory_uri(); ?>/deletefavorite.php?choices=<?php echo $description; ?>');
}
Upvotes: 0
Views: 57
Reputation: 187
I got it working. I did it with the following:
$.ajax({
type: "GET",
url: "<?php echo get_template_directory_uri(); ?>/deletefavorite.php",
data: {choices: pass},
success: function(result){
$('#ajax').html(result);
}
});
}
Upvotes: 0
Reputation: 304
Hello you can try this :
$.ajax({
type: "GET",
url: "<?php echo get_template_directory_uri(); ?>/deletefavorite.php?choices=<?php echo $description; ?>",
success: function(result){
$('#ajax').html(result);
}
});
or
$.ajax({
type: "GET",
url: "<?php echo get_template_directory_uri(); ?>/deletefavorite.php",
data: {choices: '<?php echo $description; ?>'},
success: function(result){
$('#ajax').html(result);
}
});
Upvotes: 1