Bug Tracker

Modify

Ticket #7666 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

Documentation needs to be clearer on Ajax requests

Reported by: schalk@… Owned by: ajpiano
Priority: low Milestone: 1.6
Component: web Version: 1.4.4
Keywords: Cc:
Blocking: Blocked by:

Description

For a success callback the textStatus and XHR object will not be populated if the call is a jsonp cross-domain request. All other requests, even jsonp on the same domain (although rarely if ever used), will populate the XHR object as well as the textStatus.

Change History

comment:1 Changed 2 years ago by schalk@…

You can see a sample here:  http://jsfiddle.net/tGHc5/2/

What you will notice however, is that on error, the behavior is perfectly fine. So if you change the URL in ajaxSetup to for example 'nogo', the results will be as expected.

comment:2 Changed 2 years ago by jitter

  • Priority changed from undecided to low
  • Component changed from unfiled to ajax

Cross-domain jsonp requests don't use XHR, this behavior is well documented on  jQuery.ajax()

Some types of Ajax requests, such as JSONP ..., do not use XHR; in those cases the XMLHttpRequest parameter passed to the callback will be undefined.

Actually the fact that jQuery uses XHR for non cross-domain jsonp requests is a bug see #5955 and either needs to get fixed or documented.

Last edited 2 years ago by jitter (previous) (diff)

comment:3 Changed 2 years ago by jitter

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

comment:4 Changed 2 years ago by rwaldron

I was writing this demo, based on your test case that showed the difference, so, enjoy...  http://jsfiddle.net/rwaldron/tGHc5/4/

comment:5 Changed 2 years ago by ajpiano

  • Status changed from closed to reopened
  • Resolution invalid deleted
  • Component changed from ajax to web

there are a few things that could be improved about the documentation of jsonp

comment:6 Changed 2 years ago by ajpiano

  • Owner set to ajpiano
  • Status changed from reopened to assigned

comment:7 Changed 2 years ago by ajpiano

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

updated the docs to mention that error is not fired for jsonp requests, and that the 'textStatus' argument - in addition to the XHR - will also be undefined in callbacks.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.