Pass AJAX data

1

Good afternoon everyone ...

I need to pass this information "token", "<?php echo $tokenAnuncio; ?>" ,

In this function:

function load_image_data(){
    $.ajax({
        url:"/fetch.php",
        method:"POST",
        success:function(data)
        {
            $('#image_table').html(data);
        }
    });
}

How to do it?

    
asked by anonymous 15.05.2018 / 22:39

1 answer

3

You can put it directly this way:

function load_image_data(){
    $.ajax({
        url:"/fetch.php",
        method:"POST",
        data: { token: "<?php echo $tokenAnuncio; ?>" },
        success:function(data)
        {
            $('#image_table').html(data);
        }
    });
}

And to get this information on your fetch.php page, just use the global $ _POST array, for example:

$token = $_POST['token'];
    
15.05.2018 / 22:44