A couple of questions, first with this var string below, the 1 one works but I need to get the second one working, there is a snytax error because I am not sure how to write it
var string = 'id='+ id ;
var string = 'id='+ id 'USER=1';
Second;
This ajax call below, it post to delete.php to delete a comment, it works but I would like to add in some error handling. Once I add it into the backend, how can I make it show an error in jquery ?
$.ajax({
type: "POST",
url: "delete.php",
data: string,
cache: false,
success: function(){
commentContainer.slideUp('slow', function() {$(this).remove();});
$('#load').fadeOut();
}
You’re missing a concatenation operator and an ampersand, also I wouldn’t use ‘string’ as a variable name:
That said, ‘string’ is not a JS reserved word, but still seems like bad practice (to me at least).
What you are passing in your ‘string’ variable to $.ajax is a query string, I would suggest reading this for more information:
http://en.wikipedia.org/wiki/Query_string
On your question about error handling, one way is to check the response text for something and act accordingly, e.g.: