Hmmm, I tried what you suggested, but I don't believe it does anything
but change the name of the variable inside the callback function. The
same data is being passed.





On Jan 13, 2:34 pm, Ami <aminad...@gmail.com> wrote:
> try to change the paramater name inside the success function, to
> something like "xhr",
> for example:
>
> ...
> success:function (data,xhr) {}
> complele:function (xhr) {}
> ..
>
> You uses XMLHttpRequest. Maybe the browser think about the native
> object.
> On Jan 13, 9:16 pm, bryan <br...@resenmedia.com> wrote:
>
>
>
> > Read ajax response headers?
>
> > How can I grab information from the response headers from within an
> > jQuery ajax callback?
>
> > I have an object, "data", containing IDs to different items I'd like
> > to build a detailed list with. I need to grab these details by sending
> > a request to a server--one for each item.
>
> > The issue I'm running into, is the response from the server contains
> > half the information I need in the body of the response, and the other
> > half in the headers. I can't figure out a bullet-proof way of reading
> > the headers at the same time as the body...
>
> > Here's a look at what I'm working with:
>
> > function index(data) {
>
> >         for (var i = 0; i < data.length; i++) {
>
> >                 $.ajax({
>
> >                         type: 'GET',
> >                         url: 'http://domain.com/',
> >                         data: 'this=that',
> >                         success: function(data) {
>
> >                                 /* Here I want to create a list item out of 
> > the data returned in
> > the body and headers */
>
> >                         }, complete: function(XMLHttpRequest, textStatus) {
>
> >                         }, error: function() {
>
> >                         }
>
> >                 });
>
> >         }
>
> > }
>
> > I've tried saving the $.ajax as a variable, and
> > using .getResponseHeader('name'), but that only works sometimes, and
> > other times returns "Error: INVALID_STATE_ERR: DOM Exception 11",
> > which apparently means the headers aren't ready to be read. I've tried
> > this both in the success and complete function.
>
> > Any help would be incredibly awesome!

Reply via email to