Opened 11 years ago
Closed 11 years ago
#12122 closed bug (fixed)
jQuery.ajax() async deprecate use with $.Deferred
Reported by: | 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
Change History (1)
comment:1 Changed 11 years ago by
Component: | unfiled → ajax |
---|---|
Milestone: | None → 1.8 |
Priority: | undecided → low |
Resolution: | → fixed |
Status: | new → closed |
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.