I'm trying to get the HTTP Response Code/Response Header from my AJAX request. Here's my original script:
$("#callContact1").click(function() { $.ajax({ url: "https://www.server.com?type=makecall", data: {}, type: "GET" }) .then(function(data) { $('#ajaxResponse').html(data).show(); }) .fail(function(xhr) { var httpStatus = (xhr.status); var ajaxError = 'There was an requesting the call back. HTTP Status: ' + httpStatus; console.log('ajaxError: ' + ajaxError); //make alert visible $('#ajaxResponse').html(ajaxError).show(); }) }) which is working fine. I've updated this to try and get the HTTP response code/header and view this in the console.log but I'm not seeing anything there. Here's my updated script:
$("#callContact1").click(function() { console.log('starting call back request'); $.ajax({ url: "https://www.server.com?type=makecall", data: {}, type: "GET" }) .then(function(data) { $('#ajaxResponse').html(data).show(); var httpStatus = (data.status); var httpResponseCode = (data.getAllResponseHeaders); console.log('httpStatus: ' + httpStatus); console.log('httpResponseCode: ' + httpResponseCode); }) .fail(function(xhr) { var httpStatus = (xhr.status); var ajaxError = 'There was an requesting the call back. HTTP Status: ' + httpStatus; console.log('ajaxError: ' + ajaxError); //make alert visible $('#ajaxResponse').html(ajaxError).show(); }) }) but I'm not getting anything in the console (the request is executed successfully though). I also noticed the output from the 2nd line of the updated script is also not appearing in the console either.