Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var xmlHttp = createXMLHttpRequestObject();
- function createXMLHttpRequestObject(){
- var xmlHttp;
- if(window.ActiveXObject){
- try{
- xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
- }catch(e){
- xmlHttp = false;
- }else{
- try{
- xmlHttp = new XMLHttpRequest();
- }catch(e){
- xmlHttp = false;
- }
- }
- if(!xmlHttp)
- alert("Can't create that object hoss!");
- else
- return xmlHttp;
- }
- function process(){
- if(xmlHttp.readyState == 0 || xmlHttp.readyState == 4){
- food = encodeURIComponent(document.getElementById("userInput").value);
- xmlHttp.open("GET", "store.php?food=" + food, true);
- xmlHttp.onreadystatechange = handleServerResponse;
- xmlHttp.send(null);
- }else{
- setTimeout('process()',1000);
- }
- }
- function handleServerResponse(){
- if(xmlHttp.readyState == 4){
- if(xmlHttp.status == 200){
- xmlResponse = xmlHttp.responseXML;
- xmlDocumentElement = xmlResponse.documentElement;
- message = xmlDocumentElement.firstChild.data;
- document.getElementById("underInput").innerHTML = '<span style="color:blue">' + message +'</span>';
- }else{
- alert('Something went wrong!');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement