Guest User

Untitled

a guest
Dec 7th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.         var isAjaxing = false;
  3.         var xmlHttp;
  4.         var qsMode, qsID;
  5.  
  6.         qsMode = gup("mode");
  7.         qsID = gup("id");
  8.  
  9.         if (window.XMLHttpRequest) {
  10.             // code for IE7+, Firefox, Chrome, Opera, Safari
  11.             xmlHttp = new XMLHttpRequest();
  12.         } else {
  13.             // code for IE6, IE5
  14.             xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  15.         }
  16.  
  17.         function open_notes() {
  18.             $("#modal_content").modal();
  19.             load_notes();
  20.         }
  21.  
  22.         function load_notes() {
  23.             var theDiv = document.getElementById("note_display");
  24.             xmlHttp.onreadystatechange = function () {
  25.                 if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  26.                         theDiv.innerHTML = xmlHttp.responseText;
  27.                 } else if (xmlHttp.status == 404) {
  28.                     theDiv.innerHTML = "Error retrieving notes";
  29.                 }
  30.             }
  31.  
  32.             xmlHttp.open("GET", "ajax.aspx?mode=note&do=view&id=100760&fromMode=permits", true);
  33.             //xmlHttp.open("GET", "ajax.aspx?mode=note&do=view&id=" + qsID + "&fromMode=" + qsMode, true);
  34.             xmlHttp.send();
  35.         }
  36.  
  37.         function add_note() {
  38.             if (isAjaxing) {
  39.                 return false;
  40.             }
  41.             var theSpan = document.getElementById("txtSuccess");
  42.             xmlHttp.onreadystatechange = function () {
  43.                 if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  44.                     if (xmlHttp.responseText == "true") {
  45.                         theSpan.innerHTML = "Note added!";
  46.                         load_notes();
  47.                         isAjaxing = false;
  48.                     } else {
  49.                         alert(xmlHttp.responseText);
  50.                         theSpan.innerHTML = "Error adding note";
  51.                     }
  52.                 } else if (xmlHttp.status == 404) {
  53.                     theSpan.innerHTML = "Error adding note";
  54.                 }
  55.                 document.getElementById("add_note_throbber").src = "/Styles/throbber_empty.png";
  56.             }            
  57.            
  58.             var noteText;
  59.             noteText = encodeURIComponent($("#txtAddNoteText").val());
  60.             if (noteText.length < 1) {
  61.                 theSpan.innerHTML = "Note cannot be empty";
  62.                 return false;
  63.             }
  64.            
  65.             var params = "noteText=" + noteText;
  66.             xmlHttp.open("POST", "ajax.aspx?mode=note&do=add&id=100760&fromMode=permits", true);
  67.             //xmlHttp.open("POST", "ajax.aspx?mode=note&do=view&id=" + qsID + "&fromMode=" + qsMode, true);
  68.             xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  69.             xmlHttp.send(params);
  70.             isAjaxing = true;
  71.             document.getElementById("add_note_throbber").src = "/Styles/throbber.gif";
  72.         }
Add Comment
Please, Sign In to add comment