topical media & game development
[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

talk show tell print

portal-js-ajax-functions.js



  function getXmlHttpObject() { 
          
          var objXMLHttp = null;
          
          if (window.XMLHttpRequest) {
          
                  objXMLHttp = new XMLHttpRequest();
          
          } else if (window.ActiveXObject) {
  
                  objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
          
          }
          return objXMLHttp;
  }
  
  function dispFeedItem (contentId) {
          
          xmlHttp = getXmlHttpObject();
          
          if (xmlHttp == null) {
                  alert ("Browser does not support HTTP Request");
                  return;
          }
                          
          var url = "classes/core.ajax.php?AjaxAction=DispFeedItem&ContentId="+contentId;
          xmlHttp.open("GET",url,true);
          xmlHttp.onreadystatechange = dispFeedItemStateChanged;
          xmlHttp.send(null);
          
  }
  
  function dispFeedItemStateChanged () {
          if (xmlHttp.readyState == 4) {
                                  
                  var strOutput = xmlHttp.responseText;
                                  
                  if ( (strOutput.charAt(strOutput.length - 3) + strOutput.charAt(strOutput.length - 2) + strOutput.charAt(strOutput.length - 1)) == "!@#") {
                          strOutput = strOutput.substr(0, (strOutput.length-3));
                          
                          var arrOutput = strOutput.split("%^");
                          
                          var title = arrOutput[0];
                          var description = arrOutput[1];
                          var contentId = arrOutput[2];
                                                                          
                          var htmlCode = '<b>'+title+'</b><br><br>'+description+'<br><br>Read more...</a>';
                          
                          document.getElementById("div_feed_item").innerHTML = htmlCode;
                          
                  } else {
                          alert(strOutput);
                  }
  
                  xmlHttp = null;
                  
          }        
  }


(C) A. Eliëns 2/9/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.