xide007 0 Newbie Poster

Hello everyone,

I wrote this AJAX script to process a php file to remove data from a MySQL database, but for some odd reason it isn't working so I've come here for some help, hopefully someone on here will be able to guide me to solving this issue :)

Here's my AJAX script:

<script type="text/javascript">
//-->
function removeBuddy(bud) {
$.ajax({
type: "GET",
url: "removeBuddy.php",
data: "buddy="+ bud,
success: function(msg){

$("#removed").ajaxComplete(function(event, request, settings){

if(msg == 'OK')
{

  $("#removed").css("padding", "10px", "font-size", "8pt");
  $(this).html('&nbsp;You have successfully removed <b>'+ bud +'</b> from your buddy list...');
} 
else
{

  $("#removed").css("padding", "10px", "font-size", "8pt");
  $(this).html(msg);

});

}

});

}
else
   {

   $("#removed").css("padding", "10px", "font-size", "8pt");
   $("#removed").html('FATAL: There was an error while processing your request... Please try again');
   }

});

});

}
//-->
</script>

The PHP file "removeBuddy.php" has @ the top:

$buddy = $_GET['buddy'];

If the remove was a success then the PHP file echos "OK" which as you see on the AJAX script above, one more note when it is returned to the AJAX script it's put onto a DIV called "removed" using as ID and not CLASS.

Although I think the PHP file is working but not the AJAX, which has baffled me totally... Any ideas guys ? Any help will be much appreciated!!!