I wonder whether someone may be able to help me please.
I’m using the code below to capture an ‘onlick’ event in the deletion of images. Once selected my ‘delete.php’script is called and the physical images are deleted from the server.
<script type="text/javascript">
Galleria.ready(function() {
this.$('thumblink').click();
$(".galleria-image").append(
"<span class='btn-delete ui-icon ui-icon-trash'></span>");
$(".btn-delete").live("click", function(){
var img = $(this).closest(".galleria-image").find("img");
// send the AJAX request
$.ajax({
url : 'delete.php',
type : 'post',
data : { image : img.attr('src') },
success : function(){
alert('Deleting image... ');
img.parent().fadeOut('slow');
}
});
The problem I’m having is that because the ‘click’ event is not posting the form, I’m unable to capture the ‘userid’ and ‘locationid’ variables to pass them through to the receiving script i.e. ‘delete.php.
I know this to be the problem because if I use:
<?php session_start();
$_SESSION['userid']=$_POST['userid'];
$_SESSION['locationid']=$_POST['locationid'];
The rest of my ‘delete.php’ script doesn’t work. However if I use:
<?php session_start();
$_SESSION['userid']=2;
$_SESSION['locationid']=1;
The rest of my script works fine.
I’m relatively new to PHP, and I’m unsure whether there is a solution to this.
But I just wondered whether someone may be able to have a look at this please, and offer some guidance on how I may go about overcoming this problem?
Many thanks and regards
You just need to pass the values in the data object of your ajax call: