oracle / cordova-plugin-wkwebview-file-xhr

Cordova Plugin for WebView File XHR
Universal Permissive License v1.0
138 stars 120 forks source link

How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request? #71

Closed khjung29 closed 3 years ago

khjung29 commented 3 years ago

jQuery.ajax({ url: strUrl, success: function(html) { strReturn = html; }, async:false });

async: false not working...

manish2788 commented 3 years ago

@khjung29 This issue doesn't relate to the plugin. You enquire the same in jQuery forum.

codeworrior commented 3 years ago

We encounter the same in one of our Cordova apps.

This IMHO is not a question about how to use the jQuery API. What the author does, is a correct way to send sync requests. However, the success handler is not called synchronously as expected, but asynchronously. As a consequence, any sync jQuery.ajax() does not deliver a result.

AFAIK, jQuery's implementation relies on the readystatechange event. Is there anything special (non-standard) with respect to the readystatechange event in the cordova-plugin-wkwebview-file-xhr?

codeworrior commented 3 years ago

I didn't dive too much into it, but looking at the polyfill's implementation, I think its XMLHttpRequest.prototype.send method cannot deliver the readystatechange events synchronously, because its implementation is promise based (using getHandler()).

vprabusiva commented 3 years ago

Hi, I am also faced same issue. Is there any solution??? Thanks.