What you need is access to the XMLHttpRequest object used in the request so I
suggest you use $.ajax instead of $.post. The "complete" callback for $.ajax
receives the XHR and textstatus as parameters, so this should get you the
headers:
$.ajax({url:'your.url',data:{'data1':'one','data2':'two'},complete:function(xhr,textstatus){
// xhr.responseText contains the response from the server
var allheaders = xhr.getAllResponseHeaders();
// this will get all headers as a string - if you want them as an
object...
var eachheader = allheaders.split('\n');
var headers = {};
for(i = 0; i < eachheader.length; i++) {
if ($.trim(eachheader[i]) !== '') {
headersplit = eachheader[i].split(':');
headers[headersplit[0]]=$.trim(headersplit[1]);
}
}
});
dnagir wrote:
>
>
> Hi Peter,
>
>> var ContentTypeHeader = this.contentType;
>
> "this.contentType" is the content type of the REQUEST.
> I need to get the ContentType of the RESPONSE.
>
> No chance of getting it?
>
> Cheers,
> Dmitriy.
>
>
--
View this message in context:
http://www.nabble.com/Determine-content-type-in-%24.post-callback-tp24371141s27240p24484476.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.