dymosoftware / dymo-connect-framework

DYMO Connect Framework for Javascript.
Other
88 stars 54 forks source link

Synchronous XMLHttpRequest on the main thread is deprecated #12

Open 4deeptech opened 3 years ago

4deeptech commented 3 years ago

Can you fix this issue? This was brought over from the older library.

The issue is in ajaxSync using archaic methods to fetch remote data. This causes the browser to hang/freeze during this process.

Petaht commented 3 years ago

When using the dymo.label.framework.init() the page would hang for +- 6 seconds when the local service is not installed. I wrote something dirty to check if the service is running.

function initiateDymo(host) { for(var i = 41951; i <= 41960; i++) { (function(i) { setTimeout(function(port) { $.ajax({ url : 'https://' + host + ':' + port + '/DYMO/DLS/Printing/StatusConnected', timeout: 300, dataType : 'json', success : function(data, textStatus) { // your code }, error : function(e,a) { // your code } }); }, 1, i) })(i) } }