I'm having trouble using the return data within my ajax call. What is the best way to go about this?
I simply send information to checker.jsp. It computes it. If the check is good, it responds with a Green. If it's bad, it responds with a Red.
If I use this within the success:
alert(light_color);
I get what seems to be the entire web page with the word "Red" 40 lines down. Because of this the if and elses do not work. I want to use the result and only the result. Not the html and everything in it.
What am I doing wrong?
Any help would be appreciated!
$.ajax({
type: 'POST',
url: 'checker.jsp',
data: {
'bank_cnt': bank_cnt
},
success: function (result) {
var light_color = result;
if (light_color === 'Red') {
alert('Red');
} else if (report === 'Green') {
alert('Green');
} else {
alert('didnt work');
}
}
});