Ben Aerens Ben Aerens - 5 months ago 37
Ajax Question

Pass javascript var to ajax load

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?

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; ?>');


Answer Source

I got it working. I did it with the following:

                           type: "GET",
                           url: "<?php echo get_template_directory_uri(); ?>/deletefavorite.php",
                           data: {choices: pass},
                           success: function(result){

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download