Код: Выделить всё
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);
}
}
Код: Выделить всё
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 = ""+ 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!!!');
}
Подробнее здесь: https://stackoverflow.com/questions/321 ... -with-ajax
Мобильная версия