Skip to main content

Bug Tracker

Side navigation

#12122 closed bug (fixed)

Opened July 22, 2012 10:19AM UTC

Closed July 24, 2012 08:30PM UTC

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

Reported by: szimonek@interia.pl Owned by:
Priority: low Milestone: 1.8
Component: ajax Version: 1.8b2
Keywords: Cc:
Blocked by: Blocking:
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

Attachments (0)
Change History (1)

Changed July 24, 2012 08:30PM UTC by dmethvin comment:1

component: unfiledajax
milestone: None1.8
priority: undecidedlow
resolution: → fixed
status: newclosed
summary: jQuery.ajax() async deprecation.jQuery.ajax() async deprecate use with $.Deferred

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.