Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 27th, 2012  |  syntax: JavaScript  |  size: 0.98 KB  |  views: 1,205  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function GetXmlHttpObject(handler)
  2. {
  3.    var objXMLHttp=null
  4.    if (window.XMLHttpRequest)
  5.    {
  6.        objXMLHttp=new XMLHttpRequest()
  7.    }
  8.    else if (window.ActiveXObject)
  9.    {
  10.        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  11.    }
  12.    return objXMLHttp
  13. }
  14.  
  15. function stateChanged()
  16. {
  17.    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  18.    {
  19.            document.getElementById("miasto").innerHTML= xmlHttp.responseText;
  20.    }
  21.    else {
  22.            //alert(xmlHttp.status);
  23.    }
  24. }
  25.  
  26. // Will populate data based on input
  27. function htmlData(url, qStr)
  28. {
  29.    if (url.length==0)
  30.    {
  31.        document.getElementById("miasto").innerHTML="";
  32.        return;
  33.    }
  34.    xmlHttp=GetXmlHttpObject()
  35.    if (xmlHttp==null)
  36.    {
  37.        alert ("Browser does not support HTTP Request");
  38.        return;
  39.    }
  40.  
  41.    url=url+"?"+qStr;
  42.    url=url+"&sid="+Math.random();
  43.    xmlHttp.onreadystatechange=stateChanged;
  44.    xmlHttp.open("GET",url,true) ;
  45.    xmlHttp.send(null);
  46. }
clone this paste RAW Paste Data