ciao a tutti,
io ho il seguente codice:
Codice PHP:
<script language="javascript">
//Ajax check url
var url = "cartella1/cxartella2/pagina.php?&variabile=";
function chk_me() {
//Create Temporary message
var notationS = document.getElementById("results")
notationS.innerHTML = 'Caricamento in corso....';
//Check domain here
var word_value = document.getElementById("nomepulsante").value;
http.open("GET", url + escape(word_value), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function handleHttpResponse() {
if (http.readyState == 4) {
// Split the comma delimited response into an array
var domain = document.getElementById("domain").value;
var results = http.responseText;
//If domain is valid
if(results == '0'){
var is_show = 'risultato se appare 0';
} else {
if(results == '1'){
var is_show = 'risultato se appare 1';
} else {
var is_show = 'risultato se non appare ne 0 ne 1';
}
}
var notationS = document.getElementById("results")
notationS.innerHTML = is_show;
}
}
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
</script>
io lo richiamo con:
Codice PHP:
<input name="nomecampo" type="button" id="nomecampo" onclick="javascript:chk_me();">
<div id="results" ></div>
lo script l'ho scaricato molto tempo fa su un sito, non l'ho fatto io.
ora... il mio problema è il seguente:
nel div mi appare la scritta di caricamento in corso, ma non mi esegue l'azione.... c'è qualche errore?
ps. praticamente cliccando su questo pulsante mi deve aggiungere un record in un database mysql. La query per farlo è nella pagina indicata all'inizio dello script (var url = "cartella1/cxartella2/pagina.php?&variabile=", una volta aggiunto vorrei che mi dicesse se l'operazione è andata a buon fine (a seconda del numero che appare in quella pagina che lui è andato ad eseguire).
ringrazio in anticipo chiunque mi risponda.