summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6e621f8)
Avoid aborting on this type of error, better wait for state change.
Still log "error" and "abort" events.
ref #212
Signed-off-by: Jerome Jutteau <jerome@jutteau.fr>
+function XHRErrorHandler(e)
+{
+ var text = "${e.type}: ${e.loaded} bytes transferred"
+ console.log(text)
+}
+
function pop_failure (e)
{
function pop_failure (e)
{
- var text = "An error occured";
+ var text = "<p>An error occured";
if (typeof e !== 'undefined')
if (typeof e !== 'undefined')
- text = e;
- text = "<p>" + text + "</p>";
+ text += ": " + e;
+ text += "</p>";
document.getElementById('error_pop').innerHTML = e;
document.getElementById('uploading').style.display = 'none';
document.getElementById('error_pop').innerHTML = e;
document.getElementById('uploading').style.display = 'none';
var req = new XMLHttpRequest ();
req.upload.addEventListener ("progress", upload_progress, false);
var req = new XMLHttpRequest ();
req.upload.addEventListener ("progress", upload_progress, false);
- req.addEventListener ("error", pop_failure, false);
- req.addEventListener ("abort", pop_failure, false);
+ req.addEventListener ("error", XHRErrorHandler, false);
+ req.addEventListener ("abort", XHRErrorHandler, false);
req.onreadystatechange = function ()
{
if (req.readyState == 4 && req.status == 200)
req.onreadystatechange = function ()
{
if (req.readyState == 4 && req.status == 200)
async_global_time = time;
var req = new XMLHttpRequest ();
async_global_time = time;
var req = new XMLHttpRequest ();
- req.addEventListener ("error", pop_failure, false);
- req.addEventListener ("abort", pop_failure, false);
+ req.addEventListener ("error", XHRErrorHandler, false);
+ req.addEventListener ("abort", XHRErrorHandler, false);
req.onreadystatechange = function ()
{
if (req.readyState == 4 && req.status == 200)
req.onreadystatechange = function ()
{
if (req.readyState == 4 && req.status == 200)
}
var req = new XMLHttpRequest ();
req.upload.addEventListener ("progress", async_upload_progress, false);
}
var req = new XMLHttpRequest ();
req.upload.addEventListener ("progress", async_upload_progress, false);
- req.addEventListener ("error", pop_failure, false);
- req.addEventListener ("abort", pop_failure, false);
+ req.addEventListener ("error", XHRErrorHandler, false);
+ req.addEventListener ("abort", XHRErrorHandler, false);
req.onreadystatechange = function ()
{
if (req.readyState == 4)
req.onreadystatechange = function ()
{
if (req.readyState == 4)
function async_upload_end (code)
{
var req = new XMLHttpRequest ();
function async_upload_end (code)
{
var req = new XMLHttpRequest ();
- req.addEventListener ("error", pop_failure, false);
- req.addEventListener ("abort", pop_failure, false);
+ req.addEventListener ("error", XHRErrorHandler, false);
+ req.addEventListener ("abort", XHRErrorHandler, false);
req.onreadystatechange = function ()
{
if (req.readyState == 4 && req.status == 200)
req.onreadystatechange = function ()
{
if (req.readyState == 4 && req.status == 200)