im new to javascript/ajax programming and i would like to send multiple values to the server at different stages of my program. check out my code below...
function process(){
if(xmlHttp.readyState==0 || xmlHttp.readyState==4){
Selected_word = document.getSelection();
xmlHttp.open("GET","/gwizz/scripts/definition.php?word="+Selected_word,true);
xmlHttp.onreadystatechange = handleServerResponse;
xmlHttp.send(null);
}else{
setTimeout('process()',1000);
}
}
the above function "process()" will execute when a double click is triggered on the page body. the double clicked word on the body gets sent to the server and returns is definition. the definition gets displayed on top of a pop-up modal. check out the function below "handleServerResponse()" wich gets executed after "process()" is successful.
function handleServerResponse(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
var xmlResponse = xmlHttp.responseXML;
var xmlDocumentElement = xmlResponse.documentElement;
Definition = xmlDocumentElement.firstChild.data;
$('#element_to_pop_up').bPopup({
onOpen:function(){
modal_open = time();
document.getElementById("element_to_pop_up").innerHTML = "<span style='font-weight: bold;font-size: 25pt'>"+ Selected_word;
},
onClose:function(){
modal_close = time();
document.getElementById("element_to_pop_up").innerHTML = "";
username = "beach";
//xmlHttp.open("GET","/gwizz/scripts/logfile.php?word="+Selected_word + "&username=" + username + "&modal_close=" + modal_close + "&modal_open=" + modal_open,true);
//xmlHttp.send(null);
}
});
}else{
alert('Something went wrong with process!!!');
}
}
I want to basically send other values to the server at the onClose() porperty of the modal pop-up using the same ajax object.any help would be appriciated thanks.