Bug Tracker

Modify

Ticket #12122 (closed bug: fixed)

Opened 21 months ago

Last modified 21 months ago

jQuery.ajax() async deprecate use with $.Deferred

Reported by: szimonek@… Owned by:
Priority: low Milestone: 1.8
Component: ajax Version: 1.8b2
Keywords: Cc:
Blocking: Blocked by:

Description

Hi,

In documentation on jQuery.ajax() async parameter there is: "As of jQuery 1.8, the use of async: false is deprecated." I need to argue with that. This deprecation will make my application unusable.

I'm using ZeroClipboard jQuery plugin called jquery.zclip.js to copy texts to clipboard. But the text to copy is SYNCHRONOUSLY retrieved from server before copy operation. I'm using $.ajax() call in beforeCopy zclip event, and it must be synchronous, otherwise zclip will copy to clipboard previous or none value. There is no other way (at least I don't know any) to do this.

My code (please look at beforeCopy event - that ajax call must finish and execute done() event, before copy event will be fired):

var container;

function putZeroClipboard(){

container = "";

$.ajaxSetup({

async: false, global: false, type: "POST", url: "getso.jsp", data: { uuid: $("#so-uuid").text() }, timeout: 2000

});

$("#clipboard-copy-button").zclip({

path: "/resources/swf/ZeroClipboard.swf",

copy: function(){

return container;

},

beforeCopy: function(){

$.ajax().done(function(content){

Populate variable. if (content.toString().length > 0){

container = content;

} else {

container = "\n";

}

});

}

});

}

The problem is, that all event in ZeroClipboard and zclip (beforeCopy, copy, afterCopy), are fired from flash action script. So if value to copy to clipboard is prepared in event beforeCopy, it must already be prepared when beforeCopy event ends, and that is only possible when using synchronous AJAX call.

Best regards Simon

Change History

comment:1 Changed 21 months ago by dmethvin

  • Status changed from new to closed
  • Component changed from unfiled to ajax
  • Summary changed from jQuery.ajax() async deprecation. to jQuery.ajax() async deprecate use with $.Deferred
  • Priority changed from undecided to low
  • Milestone changed from None to 1.8
  • Resolution set to fixed

Documentation updated to clarify that async: false is still allowed but that use with $.Deferred is deprecated. The use shown above with callbacks is not deprecated.

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.