0

I've got several div id's, each containing a different client. I want to be able to click the delete button and using ajax and jquery delete the specific div from the database. I'm getting success in AJAX but it's not deleting anything from the DB. And then obviously, upon deletion, I would like the container to reload dynamically. help!!!

function DeleteClient(){
clientID = $('.clientblock').attr('id')
alert(clientID);
 var yes = confirm("Whoa there chief! Do you really want to DELETE this client?");

 if (yes == 1) {
 dataToLoad = 'clientID=' + clientID + '&deleteclient=yes',

 $.ajax({
 type: 'post',
 url: '/clients/controller.php',
 datatype: 'html',
 data: dataToLoad,
 success: function(html) {
 alert('Client' + clientID + ' should have been deleted from the database.');
 $('#clientscontainer').html(html); 
 },
 error: function() {
 alert('error');
 }});};
 };

controller.php info //
Variables necessary are:
$deleteClient
$clientID

on the delete click, when being passed through post (via firebug)
clientID = 0
deleteClient = yes

edit: so obviously, it's not getting the correct client ID to delete it to the DB as it is passing through post but I am getting an ajax success call and where i have the client ID variable displaying there, it is picking the correct client ID.

 
alert(clientID) is pulling in 0 as well.  

Any ideas?

1
  • 1
    You will have to put some info about your controller.php here. Try to use Firebug to track the post to the controller to see whats happening - the parameters, etc. Commented Apr 12, 2010 at 22:45

1 Answer 1

2
dataToLoad = 'clientID=' + clientID + '&deleteclient=yes',

Your controller is getting clientID value of 0.

Track down your clientID javascript variable and see if it is fetching the correct clientID.

Sign up to request clarification or add additional context in comments.

1 Comment

I was able to get it to correctly identify the clientID variable and that seemed to do the trick. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.