Changing the button class by the received data

I have this JQ code:

$("button").click(function() {
        url: 'ajax.php?act=complete&id=' +,
        success: function(data){
             if (data == "Not good")

the alert(data) can alert only 2 things from the ajax.php file:
“Not good” and “Good”. (echo’s in PHP in the ajax.php file)

I decided to try and compare it to Not good and if it’s a match, change the button class to red.
The code doesn’t work. (if I put the class-change code before the IF, it does work).

What’s the problem here?

Comment out the alert, and use curly braces around your conditional, ie if(condition){function}else{otherFunction}

Also, trim the value of data before comparing - PHP might be putting some whitespace in there, somewhere. :slight_smile: