-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); 
  }
});
Jai
  • 74,255
  • 12
  • 74
  • 103
Divya
  • 59
  • 1
  • 9

2 Answers2

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); 
  }
});
Bharatsing Parmar
  • 2,435
  • 1
  • 9
  • 18
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); 
  }
});
David Lee
  • 1
  • 2