// ########################### CREATE THE REQUEST OBJECT ####################### function createXMLHttpRequest() { var ua; if(window.XMLHttpRequest) { try { ua = new XMLHttpRequest(); } catch(e) { ua = false; } } else if(window.ActiveXObject) { try { ua = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { ua = false; } } return ua; } var req = createXMLHttpRequest(); var img="" // ############################## SEND THE REQUEST ########################### function sendRequest(id) { req.open('get', 'func.php?id=' + id); req.onreadystatechange = handleResponse; req.send(null); } // ############################# HANDLE RESPONSE ########################### /*---------------------------- AJAX readyState Status Codes: 0 - uninitialized 1 - loading 2 - loaded 3 - interactive 4 - complete ------------------------------*/ function handleResponse() { if(req.readyState == 4) { var response = req.responseText; var update = new Array(); if(response.indexOf('||' != -1)) { // the response comes through as string // it's seperator is || //it sends the name of the div then a || // and the text to add to the div. update = response.split('||'); //document.getElementById('Recipe_Status_Div').innerHTML='' document.getElementById(update[0]).innerHTML = update[1]; } } else { //document.getElementById('Recipe_Status_Div').innerHTML=img } }