-1

Here i am calling one API, i am getting success response but they returning the total count header part , i don't know how to take the values.
See Here:
enter image description here

$.ajax({
  url: '//www.examples.com/api/get/',
  type: 'GET',
  contentType: 'application/json; charset=utf-8',
  success: function(result) {
    console.log(result);
  },
  error: function(errMsg) { 
    //console.log(errMsg); 
  }
});

1
  • Try Response tab. Commented Jan 7, 2017 at 10:22

2 Answers 2

2

Try this: request.getResponseHeader('x-Total-Count') in success callback

$.ajax({
  url: '//www.examples.com/api/get/',
  type: 'GET',
  contentType: 'application/json; charset=utf-8',
  success: function(data, textStatus, request){
        alert(request.getResponseHeader('x-Total-Count'));
   },
  error: function(errMsg) { 
    //console.log(errMsg); 
  }
});
Sign up to request clarification or add additional context in comments.

Comments

0

the success callback has 3 params, you can Click here

$.ajax({
  url: '//www.examples.com/api/get/',
  type: 'GET',
  contentType: 'application/json; charset=utf-8',
  success: function (result, textStatus, xhr) {
    console.log(xhr.getResponseHeader('X-Total-Count'));
  },
  error: function(errMsg) { 
    //console.log(errMsg); 
  }
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.