title: ajax + php + json = login
body: <p>I've made a login that uses ajax to send the form to a php file which should return the result..however in a couple of browsers I get errors, while in firefox it seems to work like a charm.
  JS:</p>
  
  <pre><code>    $.ajax({
          type: "POST",
          url: "http://www.xxxxxx.net/login.php",
          data: dataString,
          dataType: "json",
          success: function(json) {
              if(json.jresult==false){
                  alert(json.jerror);
              }
              else{
                  if(json.identification==0 || json.identification==1){
                      // register: do some stuff
                  }
                  else if(json.identification==2){
                      //  login: do some stuff
                  }
                  else{
                      return(false);
                  }
              }
          },
          error: function(xhr, textStatus, errorThrown) {
              alert('error:'+errorThrown+',status:'+textStatus+',xhr:'+xhr);
          },
          complete: function(jqXHR, textStatus) {
              alert(textStatus);
          }
      });
  </code></pre>
  
  <p>Errors I get from the ajax call using Safari,Opera and Rockmelt:</p>
  
  <p><strong>@complete function:</strong> textStatus=error
  <strong>@error function:</strong> error:,status:error,xhr: [Object object]</p>
  
  <p>PHP:</p>
  
  <pre><code>session_cache_limiter('nocache');
  header('Expires: '.gmdate('r',0));
  header('Content-type: application/json');
  // set response array
  $aDataR = array();
  $aDataR['jresult'] = false;
  $aDataR['identification'] = -1;
  if(!isset($_POST['iID'])){
  }
  else{
      if($_POST['iID']==0){
          /* REGISTER */
      }
      elseif($_POST['iID']==1){
          /* LOST PASS */
      }
      elseif($_POST['iID']==2){
          /* LOGIN */
          $aDataR['identification'] = 2;
          if(false==($mResponse = $cChallenges-&gt;CheckLogin($_POST['sUser'],$_POST['sPass']))){
              $aDataR['jerror'] = "No such user/password combination";
              $cChallenges-&gt;ProbeLogin($_POST['sUser'],$_SERVER['REMOTE_ADDR']);
          }
          else{
              $aDataR['jresult'] = true;
              $aDataR['jsuccess'] = "Thanks for logging in";
          }
      }
  }
  echo htmlspecialchars(json_encode($aDataR), ENT_NOQUOTES);
  </code></pre>
  
  <p>Left out all code that wasn't important.
  Hope anyone can help me out on this one, thanks in advance.</p>