Thread: if/else fail?

    #1
  1. No Profile Picture
    Super Moderator
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,531
    Rep Power
    111

    if/else fail?


    Solved... The first reference to data in my if/else conditions was misspelled as date. *rolls eyes*

    I'm sure I'm overlooking something basic here. I've re-written the 'populateSelect' item to rule out accidental characters. The alert(data[0]); alerts populateSelect exactly as expected. However, the if(data[0] == 'populateSelect') appears not to be TRUE, so I don't get the alert('Ummm...'); or any actions within. Any ideas?
    Code:
    success : function(data) {
      alert(data[0]);  // populateSelect
      if(date[0] == 'reload') {
        location.reload(true);
      } else if(data[0] == 'populateSelect') {  // Does not appear TRUE
        alert('Ummm...');
        this.html(data[1]);
        this.append($('<input />', { type: 'hidden', value: values }));
      } else if(data[0] == 'updateTotals') {
        $().updateTotals(data);
      } else if(data[0] == 'redirect') {
        window.location.href='?page=invoice';
      } else if(data[0] == 'error') {
        alert(data[1]);
      }
    },
    Last edited by Triple_Nothing; December 28th, 2017 at 02:19 PM.
    He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.

IMN logo majestic logo threadwatch logo seochat tools logo