Subversion Repositories logviewer

Rev

Go to most recent revision | View as "text/javascript" | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. function _solve(id) {
  2.         var xhr = new XMLHttpRequest();
  3.         xhr.onreadystatechange = function () {
  4.                 if (xhr.readyState === 4 /* DONE */) {
  5.                         if (xhr.status !== 200 /* OK */) {
  6.                                 alert('Generic network failure. Please try again.');
  7.                                 return;
  8.                         }
  9.                         try {
  10.                                 obj = JSON.parse(xhr.responseText);
  11.                         } catch (e) {
  12.                                 alert('Server side error!');
  13.                                 return;
  14.                         }
  15.                         if (!obj.success) {
  16.                                 alert(/* 'JSON server error: ' + */ obj.error);
  17.                                 return;
  18.                         }
  19.                         if (document.getElementById('line'+obj.id).style.display != 'none') {
  20.                                 document.getElementById('line'+obj.id).style.display = 'none';
  21.                                 document.getElementById('count').innerHTML = document.getElementById('count').innerHTML - 1;
  22.                         }
  23.                 }
  24.         };
  25.         xhr.open('POST', 'ajax_cmd.php', true);
  26.         xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  27.         xhr.send('cmd=solve&id='+id);
  28. }
  29.