A little bit of a jQuery / Ajax problem

I’m still getting a response back no matter what, I think if I ever redo my trivia game I would use error codes. However for just simple validation this will work:

An I know where the response is going to in JQuery:
[php] var myData = {
‘action’ : ‘save’,
‘username’ : $username.val(),
‘password’ : $password.val(),
‘verify’ : $verify.val(),
‘firstName’ : $firstName.val(),
‘lastName’ : $lastName.val(),
‘emailAddress’ : $emailAddress.val()
};

$.post('ajax.02.php', myData, function(response) {
   
  /* Load json data from server and output appropiate message */
  if(response.type === 'error') {
    $password.val('');
    $verify.val('');
    $status.css({
      'background-color' : 'red'
    });
    output = response.text; // Display the error message:
    $status.animate({width: 'toggle'}, 350); // Slide the error/success container div down:
    displayTimer(12);
  } else { // Display to screen if successful:
    $status.css({
      'background-color' : 'green'
    });
    $('#register input[type="text"], #register input[type="password"]').each(function() {
      $(this).val(''); // Clear input fields:
    });        
    $username.focus(); // Set Focus on first input tag:        
    output = response.text; // Grab the success message from php:
    $status.slideDown(500);
    displayTimer(6); // Call Timer and only display it for so many seconds:
  }
  $message.text(output); // Set the text in the p tag with the result class:
  
  
}); // End of Post Data to Server Function:[/php]

The red bothers me for the simple fact that if there is something wrong elsewhere in the javascript (JQuery) the first thing I do is look at the console and go “Oh know an error just halted my script”. Like I said I’m being nit picky. To me it should have been may a yellow or dark yellowish or maybe a different color meaning “Yeah, it’s an error but a control error”. Though I might use error codes with checking single inputting of input tags…hmmmm :-\ Me Dr. Jekyll and Mr. Hyde. :smiley:

The more I look at the code the more I think it would be easy just to throw the errors codes in…OK I’m going crazy. :-\

Sponsor our Newsletter | Privacy Policy | Terms of Service