Bug Tracker

Ticket #4110 (closed bug: fixed)

Opened 6 years ago

Last modified 3 years ago

beforeSend is ignored in Firefox 3 with JQuery 1.3.1

Reported by: radu3000 Owned by:
Priority: undecided Milestone: 1.3.2
Component: ajax Version: 1.3.1
Keywords: beforeSend ajax request header Cc: radu_marian@…
Blocking: Blocked by:

Description

I am not able to set any request headers inside beforeSend. See complete example below:

<html> <head> <title>Hello.html</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript">

$.ajax({

url: " http://api.cnet.com/restApi/v1.0/techProduct?productId=32069546&iod=none&viewType=json&partKey=19926949750937665684988687810562", dataType: "jsonp", beforeSend: function(xhr){

alert('help - i am ignored'); xhr.setRequestHeader('myCustomHeader', '100');

}, success: function(data){

alert(data.CNETResponse.TechProduct.EditorsRating.$);

$("div#html").append(data.CNETResponse.TechProduct.EditorsRating.$);

}

});

</script> </head> <body> <fieldset><legend>Loaded from an test.html file</legend> <div id="html"> <h1>Hello!</h1> </div> </fieldset> </body> </html>

Change History

comment:1 Changed 6 years ago by radu3000

JSONP is not using XMLHttpRequest at all - like the following post says already:  http://groups.google.com/group/jquery-dev/browse_thread/thread/e7eb4a23eef342fb

Too bad there is not enough documentation in the jQuery API.

Regards, Radu.

comment:2 Changed 6 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to fixed

I have updated the documentation to reflect the implementation. In particular, since they are implemented via a script tag the cross-domain requests do not provide an XHR object in their callbacks and do not fire beforeSend or processData.

 http://docs.jquery.com/Ajax/jQuery.ajax

comment:3 Changed 5 years ago by dandv

  • Status changed from closed to reopened
  • Resolution fixed deleted

If JSONP requests are done via <script src=>, and are not using XMLHttpRequest at all, is there a use case for providing the 'jsonp' option for jQuery.ajax?

I might be wrong, but when doing a JSONP request, there's nothing to specify to jQuery.ajax that one can't do in jQuery.getJSON. In that case, the 'jsonp' option is confusing (I came here for the same reason, that beforeSend was never called).

comment:4 Changed 5 years ago by dmethvin

  • Status changed from reopened to closed
  • Resolution set to fixed

This is working as documented; it's just not possible to set request headers on a jsonp request.

Note: See TracTickets for help on using tickets.