0

I'm trying to get response header using AJAX, but it doesn't work. Apparently I did't do it right:

$.ajax({ type: 'GET', url:'http://www.somesite.com/', data: formData, success: function(data, textStatus, XMLHttpRequest){ alert(XMLHttpRequest.getResponseHeader('some_header')); } error: function (XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.getResponseHeader('some_header')); } }); 

I also try this one:

$.ajax({ type: "GET", url: 'http://www.somesite.com/', complete: function(xhr) { alert(xhr.getAllResponseHeaders()); } }); 

Any help?

2
  • What is the error message you get? What happens? Commented Apr 2, 2013 at 17:00
  • In console: Uncaught SyntaxError: Unexpected identifier Commented Apr 2, 2013 at 17:02

1 Answer 1

1

You are missing a comma.

success: function(data, textStatus, XMLHttpRequest){ alert(XMLHttpRequest.getResponseHeader('some_header')); }, // <------------- 
Sign up to request clarification or add additional context in comments.

2 Comments

I added comma, but still doesn't work. Console: Uncaught ReferenceError: formData is not defined.
I'm not psychic, I have no idea what formData is. Do you declare it? What is its value?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.