Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>the <strong>reg.onreadystatechange</strong> is a block function, and is gets called every time your state changes. It is therefor being called during the call, as well as after the call. (twice, possibly more)</p> <p>Also, a sidenote, remember that dr.dk is very furious when someone leeches content from their site, or even just links at them from other sites...</p> <p>In your else statement, you need to listen specifiaclly on a fail. Suggested structure :</p> <pre><code>request[requestid].onreadystatechange = function() { /* This is a slightly confusing part of the script. We don't wait to hear back from the server before we continue with the communicate() function. It sends the request, and if and when the server gets back to us, whatever's specified as request[requestid].onreadystatechange is performed. So, we have to define .onreadystatechange BEFORE we actually make contact with the server. If you're reading this and trying to learn how it works, you may want to take a glance at the last part of the communicate() function first, and then come back here. */ try { /* We use try and catch because Javascript will give an error when we try to access request[requestid].status if the server is down or if the user navigates away from the page. */ if (request[requestid].readyState == 4 &amp;&amp; request[requestid].status == 200) { window.clearTimeout(timeout[requestid]); document.body.style.cursor = 'default'; /* 4 = The AJAX Request is complete; 200 = The HTTP server found the data we needed and was able to send it to us. */ eval(request[requestid].responseText); } else if (request[requestid].readyState == 4 &amp;&amp; request[requestid].status != 200) { window.clearTimeout(timeout[requestid]); if (failure) eval(failure); document.body.style.cursor = 'default'; alert ('Error ' + request[requestid].status + ': Server error. If you entered data, it may or may not have been saved. Please contact your systems administrator.'); } } catch(e) { window.clearTimeout(timeout[requestid]); document.body.style.cursor = 'default'; if (failure) eval(failure); alert ('Error: Unable to communicate with server. Please contact your systems administrator. You may want to try again in a few minutes to see if the problem fixes itself. \n\n(Either the server was down, the communication was interrupted, or there was an error in the data sent by the server.)\n' + e + '\n\n' + request[requestid].responseText); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload