Ciao ragazzi, sono nuovo
Mi presento, sono Matteo da Rimini, leggo costantemente il vostro forum e lo trovo utilissimo...
ultimamente sono intoppato in un problema...
sto cercando di creare una sorta di "piazza" come le discussioni di facebook, tutti gli iscritti possono postare e comparirà il messaggio in un div sottostante (anchesso aggiornato in ajax)
il mio problema è il passaggio del commento... non mi piaceva fare il refresh della pagina, anche perchè aggiornerebbe anche tutto il resto...
<form name="form" method="GET">
<input type="hidden" id="autore" name="autore" value="<?php echo $CI->session->userdata["member_id"] ?>" />
<input type="hidden" id="username" name="username" value="<?php echo $CI->session->userdata["username"] ?>" />
<input type="hidden" id="mail" name="mail" value="<?php echo $CI->session->userdata["email"] ?>" />
<input type="hidden" id="url" name="url" value="<?php echo $CI->session->userdata["url"] ?>" />
<input type="hidden" id="location" name="location" value="<?php echo $CI->session->userdata["location"] ?>" />
<input type="hidden" id="ip" name="ip" value="<?php echo $CI->session->userdata["ip_address"] ?>" />
<input type="hidden" id="commentodata" name="commentodata" value="<?php echo time(); ?>" />
<table width="270" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="227">
<textarea id="commento" name="commento" cols="35" rows="3"></textarea>
</td>
<td width="43" align="center">
<input name="textfield" type="text" id="textfield" size="5" maxlength="3" />
<input onclick="display_data()" value="Invia" type="button"/>
</td>
</tr>
</table>
</form>
---
questo è il mio form, con tutti i valori che devo passare
<script language="JavaScript" type="text/javascript">
function display_data() {
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null) {
alert ("Il tuo browser non supporta HTML5");
return;
}
var autore = document.form.autore.value;
var username = document.form.username.value;
var mail = document.form.mail.value;
var url = document.form.url.value;
var location = document.form.location.value;
var ip = document.form.ip.value;
var commentodata = document.form.commentodata.value;
var commento = document.form.commento.value;
var url = 'processchat.php?autore='+autore+'&username='+user name+'&mail='+mail+'&url='+url+'&location='+locati on+'&ip='+ip+'&commentodata='+commentodata+'&comme nto='+commento;
alert(url);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete") {
document.getElementById('results').innerHTML=xmlht tp.responseText;
}
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function GetXmlHttpObject() {
var xmlhttp=null;
try {
// Firefox, Opera 8.0+, Safari
xmlhttp=new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlhttp;
}
</script>
---
e questa è la funzione che viene richiamata dal button sul form...
purtroppo non passa le variabili...
ho messo un ALERT per far vedere a schermo la stringa che passa...
provato anche con FIREBUG per vedere se il form mi manda qualcosa in uscita ed il risultato è si...
ma la mia pagina di destinazione in php, dove ci sta la query sul db messaggi sembra non ricevere nulla...
idee?
Grazie...
ps: ho cambiato 5 o 6 tipi di strutture ajax reperiti in rete ma funzionavano meno di quello che uso ora...



Rispondi quotando

