Advertisement
DArcher

AJAX (modified from TigZag tut)

Feb 23rd, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function OnCheckAvailability(){
  2.     var ajaxRequest;
  3.     try{
  4.         ajaxRequest = new XMLHttpRequest();
  5.     } catch (e){
  6.         try{
  7.             ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  8.         } catch (e) {
  9.             try{
  10.                 ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  11.             } catch (e){
  12.                 alert("Your browser does not support AJAX!");
  13.                 return false;
  14.             }
  15.         }
  16.     }
  17.     var qstring = "query="+document.getElementById("question").value;
  18.     ajaxRequest.open("POST", "checkdatabase.asp", true);
  19.     ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  20.     ajaxRequest.setRequestHeader("Content-length", qstring.length);
  21.     ajaxRequest.setRequestHeader("Connection", "close");
  22.  
  23.     ajaxRequest.onreadystatechange = function(){
  24.         if(ajaxRequest.readyState == 4){
  25.             document.getElementById("Available").innerHTML = ajaxRequest.responseText;
  26.         }
  27.     }
  28.     ajaxRequest.send(qstring);
  29. }
  30.  
  31.  
  32. JQUERY VERSION
  33. $("#post").click(function(){  
  34.         $("#result").html(ajax_load);  
  35.         $.post(  
  36.             loadUrl,  
  37.             {language: "php", version: 5},  
  38.             function(responseText){  
  39.                 $("#result").html(responseText);  
  40.             },  
  41.             "html"  
  42.         );  
  43.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement