title: IE8 and Jquery .post ajax call not working
body: <p>The below ajax call submits form data and receives feedback from a server as a json encoded object/array. Works on IE10, and the latest versions of FF and Chrome.</p>
  
  <p>Does not work in IE8. Using IE8 developer tools i could see the json array was actually returned from my server to my browser. However at the line with the "$.each" statement it completely skips that loop, as if there was no data in the ajax response.</p>
  
  <p>Does anyone know what the issue is? I read other forums some suggested using datatype = json, but not sure how to fit that in my code. Others suggested changing .post to .ajax. But i dont' want to make changes before i actually understand why IE8 is failing at this.</p>
  
  <pre><code>$.post( "&lt;?php echo Router::url(array('controller'=&gt;'Bookings','action'=&gt;'saveBooking_ajax')); ?&gt;", $( ".reservationform" ).serialize(), function() {
  
              })
                  .done(function(data) {
  
                      parseddata = JSON.parse(data); 
  
                      //IE8 totally skips this next part even if parseddata has data
                      $.each(parseddata, function(key, value) {
                          if (key == "status") status = value;
                          if (key == "message") message = value;
                          if (key == "failuretype") failuretype = value;
                          if (key == "bookingref") bookingref = value;
                      });
  </code></pre>
  
  <p>example of return response from server:</p>
  
  <pre><code> {"status":true,"failtype":"USER","message":"","timeslots":[[{"18:00:00":"6:00 pm"},{"18:10:00":"6:10 pm"},{"18:20:00":"6:20 pm"},{"18:30:00":"6:30 pm"},{"18:40:00":"6:40 pm"},{"19:20:00":"7:20 pm"},{"19:30:00":"7:30 pm"},{"19:40:00":"7:40 pm"},{"20:20:00":"8:20 pm"},{"20:30:00":"8:30 pm"},{"20:40:00":"8:40 pm"}]]}
  </code></pre>
  
  <p><strong>ANSWERED USING @BARMAR ANSWER</strong></p>
  
  <p>I've changed the code to use the "json" parameter as part of my .post call.</p>
  
  <p>I believe this automatically parses the return as a json object, hence I did not have to call JSON.parse(data) in the done() function anymore. JSON.parse(data) does not work in IE8 anyway. Note that i did not try using "$.parseJSON()" as suggested by Barmar.</p>
  
  <pre><code>            //parseddata = JSON.parse(data);
  </code></pre>
  
  <p>Also I then accessed the return object variables directly as suggesed:</p>
  
  <pre><code>            status = data.status;
              message = data.message;
              failtype = data.failtype;
              timeslots = data.timeslots;
  </code></pre>
  
  <p>This seems to work in most cases. But does not work in IE8 for variable "Status"! because the variable "status" has for some reason on page load been typed as a string with no value, and cannot be passed the value of data.status which is a true non-string boolean value. Hence variable "status" remains as "". Other variables seem fine.</p>
  
  <p>This is strange because this works on other modern browsers, the variable "status" is already typed as an empty string "", and despite data.status = true, it somehow successfully assigns the value to "status", giving variable "status" the string version of the boolean value "true". </p>
  
  <p>Sorry if this is long winded, but despite IE8s inability to a pure boolean value to a string variable, I think i should just stop using "status" as a variable name for the fact that somewhere unknown its already being typed and initialized as "".</p>
  
  <p>See debug screen in firefox where var "status" is mysteriously pre-typed as an empty string. The same shows in IE.</p>
  
  <p><img src="https://i.stack.imgur.com/YnJMI.jpg" alt="enter image description here">
  I also realized i should be declaring variables within the callbacks using "var". Not using var had resulted them in getting being of global scope and were holding the same values from previous callbacks.</p>
  
  <p>Anyway, I'm marking this question as answered as the original question has been answered.</p>