Allora avevo ragione io...e la discussione andava messa in javascript :P
Non è difficilissimo, l' ho fatto io lo puoi fare anche te, la logica è questa:
Io non ci smanetto troppo con ajax, però ogni tanto uso questo codice:codice:<div id="miodiv"> Questo div cambierà il suo contenuto dopo che sarà effettuata la chiamata con ajax ad un file php </div> <a href="#" onclick="ajaxRequest()">Click</a>
Poi il crei il file php che riceve la variabile e cerca nel DB, tutto l' output che generi col file php sarà inserito nel divcodice:<script> function xmlhttp() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } return xmlhttp; } function ajaxRequest(AjaxMethod, AjaxFile, AjaxHtml, AjaxParams) { //alert('Funzione ajaxRequest caricata correttamente\n\r'); //+ '\n\r'+AjaxMethod + '\n\r'+AjaxFile + '\n\r'+AjaxHtml + '\n\r'+AjaxParams); var xhr, AjaxText; AjaxText = document.getElementById(AjaxHtml); //AjaxFile = AjaxFile + "?timestamp=" + new Date().getTime(); try { window.XMLHttpRequest ? xhr = new XMLHttpRequest() : xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { AjaxText.innerHTML = "AJAX non funziona sul tuo browser"; } xhr.onreadystatechange = function() { /* Gli stati di una richiesta possono essere 5 * 0 - UNINITIALIZED * 1 - LOADING * 2 - LOADED * 3 - INTERACTIVE * 4 - COMPLETE */ AjaxText.innerHTML="<img src='images/loading.gif' height='40px'>"; if (xhr.readyState == 4) { setTimeout ( function() { xhr.status == 200 ? AjaxText.innerHTML = xhr.responseText : AjaxText.innerHTML = "Si � verificato un errore nel tentativo di usare AJAX"; }, 2000 ); } } if (AjaxMethod == "GET") { AjaxFile = AjaxFile + "&" + AjaxParams; //alert(AjaxFile); xhr.open(AjaxMethod, AjaxFile, true); xhr.send(); } else { xhr.open(AjaxMethod, AjaxFile, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(AjaxParams); } } </script> <div id="miodiv"> Questo div cambierà il suo contenuto dopo che sarà effettuata la chiamata con ajax ad un file php </div> <a href="#" onclick="ajaxRequest('GET', './dir/ajax_file.php?id='3', 'miodiv', '')">Click</a>

Rispondi quotando
