Something goofy with Ajax readyState

In the code below, the script suggest.php will return “Fail1” if the passed value s is blank. It will return “Fail2” if the user is not logged in, and it will return “Suggestion” if everything worked as it should.

Now, if the user is not logged in and tries to submit a suggestion, I have been getting the alert(“You must have an account to add new Suggestions !”) TWICE.
I can’t figure out why . The sequence of readyStates is:
4, – Get the message here
1 – Get the message again, HUH??

function addsuggest(s,c) {
  var url = "suggest.php?suggession="+s+"&catid="+c;
  var xmlHttp = getXMLHttp();
  try {
    xmlHttp.onreadystatechange = function() {
      if (xmlHttp.readyState == 4) {
        msg = xmlHttp.responseText;
        if(msg == "Suggestion") {
          alert("Suggestion posted successfully....");
          return true;
        if(msg == "Fail1") {
          alert("Suggestion Text was blank?");
          msg = '';
          return false;
        if(msg == "Fail2") {
          alert("You must have an account to add new Suggestions !");
          msg = '';
          return false;
    }"GET", url, true);
  catch(err) {

Any ideas as to why this is happening?

Are you sure that nothing in the code you haven’t shown is allowing the function to be called twice?
Try an alert right at the start of the function.