Banging head with a strange js problem

Hai folks,

first please do not ask me why not tyring jquery insted of js. that is another question that can be answerd at the end of the solution. now lets come to the question.

     var result = xmlhttp.responseText;

     if(result=='Require Login'){
        alert("Please login to shortlist properties.");
        return false;
     }else if(result=='already'){
        alert("You have already shortlisted this property. To manage your shortlist, please visit your dashboard.");
        return false;
        document.getElementById(id).style.backgroundImage = 'url(images/added_tofav.png)';

now when the result is “already”, it should process the ‘else if’ part right. but strange when it is “already”, it process the else part which is changing the background. what’s worng???

Add a console.log() after setting the variable result.

var result = xmlhttp.responseText;

What is the output?

1 Like

hai pullo,
when your reply arrives, i had also found the problem same time :smile:
This did the job, but strange it does not have any space charctors showing when i view the out put in console (firebug) or when i alert the out put


Thank you for your answer too.

No problem :smile:
Glad you got it sorted.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.