title: Ajax error and Uncaught SyntaxError: Unexpected token error
body: <p>I know there has been a thousand topics on this error, but none seem to match my issue.  The usual answers appear to be invalid json or a problem with the datatypes in the ajax call.
  All json I send back is from php's json_encode.</p>
  
  <p>My problem seems to be a bit weirder:</p>
  
  <p>I am creating an application and this runs perfectly fine on the server at work (windows server 2008, IIS 7, PHP 5.3), and even locally on a work pc using WAMP, and on my home server which is windows 7 with IIS 7 and PHP 5.4.</p>
  
  <p>However, recently when copying my application over from work to home (via Dropbox - no code changes whatsoever), suddenly every single ajax call made by jQuery is not working correctly... but it also does;</p>
  
  <ul>
  <li>using console.log(data) I can see that what is being returned is
  exactly what should be.</li>
  <li>but any if statement etc doesn't recognise the value</li>
  </ul>
  
  <p>For example, my login script echos true from php (interpreted by JS as '1') if logged in, and I can see this 1 being sent back with console.log - but JS then doesn't recognise this when I use (data == 1) or data == '1', I'm baffled as to how JS can recognise data in console.log, but not in an if statement on the next line.</p>
  
  <p>I get this same problem for absolutely any ajax call on any page of the application, whether JSON.parse, $.parseJSON or just standard post is being used to decipher the return value.  I have also tried using dataType json for these calls with no success.
  When I do try using json datatype I get 'Uncaught SyntaxError: Unexpected token', but no errors at all for standard post and post backs.  All calls work perfectly on the work server.</p>
  
  <p>Here is the ajax success of my login call:</p>
  
  <pre><code>success: function(data) {
  console.log(data);
  if (data == 1) {
  window.location = (window.lasturl == "" ? "index.php" : window.lasturl);
  } else {
  $form.after('failed to login, username and password may be incorrect - please try again');
  }
  </code></pre>
  
  <p>Where $form is set to the login form.</p>
  
  <p>console.log shows: 1
  but the data == 1 if statement is not performed, and the else statement is.</p>
  
  <p>It's doing my head in!</p>
  
  <p>Any ideas?</p>