Bug Tracker

Modify

Ticket #5507 (closed bug: duplicate)

Opened 4 years ago

Last modified 4 years ago

Ajax Fires "Complete" Event Twice (JSONP)

Reported by: Wardrop Owned by:
Priority: major Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

When using $.ajax() for JSONP requests, the "complete" event is fired twice if the JSONP request is from and to the same domain.

You could argue that JSONP shouldn't be used for same-domain JSON requests, but there are circumstances where this does occur for whatever reason, such as in a testing environment where the JSONP resides under the same domain (which may be 'localhost').

This isn't a hard one to reproduce, but here's some sample code anyway...

<script src="jquery-1.3.2.js"></script> <script>

$.ajax({ type : "GET",

url : <insert url here>, async : false, dataType : "json", complete : function () { alert('complete'); }

});

</script>

Simply replace <insert url here> with a JSONP URL from the same domain the script is run from, and then repeat the test with a JSONP URL from another domain.

Change History

comment:1 Changed 4 years ago by dmethvin

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

Duplicate of #5383.

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.