Ciao, ho un problema che non ho capito. Vi copio il codice, sono 2 funzioni che fanno la stessa cosa. La prima funziona, la seconda no...senza darmi alcun errore javascript
Codice PHP:
window.addEvent('domready', function() {
var text = $('divRicerca_msg');
var cerca = new Request.HTML({
url: 'posta/do_nuovo_messaggio.php?azione=cerca', // l'url da contattare
method: 'post',
//update: text, // l'elemento che verrÃ_ aggiornato al completamento della richiesta
evalScripts: true, // gli script contenuti nel responso non verranno azionati
onRequest: function() {
//text.set('html', 'Request is running...');
},
onComplete: function(tree, elements, html, js) {
//onComplete: function(html) {
//text.set('html', html);
//alert(tree);
//eval(js);
for(i=$('selCerca_destinatario').options.length-1;i>=0;i--)
{
$('selCerca_destinatario').remove(i);
}
var cercati = html.split("|");
for (i=0;i<cercati.length;i++)
{
var aux = cercati[i].split("@");
var newoption = new Option(aux[0], aux[1]);
try
{
$('selCerca_destinatario').add(newoption, null);
}
catch (err)
{
$('selCerca_destinatario').add(newoption);
}
}
},
onFailure: function() {
//text.set('html', 'The Request has failed...');
}
});
var posta = new Request.HTML({
url: 'posta/do_nuovo_messaggio.php?azione=invia', // l'url da contattare
method: 'post',
//update: text, // l'elemento che verrÃ_ aggiornato al completamento della richiesta
evalScripts: true, // gli script contenuti nel responso non verranno azionati
onRequest: function() {
text.set('html', 'Request is running...');
},
onComplete: function(tree, elements, html, js) {
//onComplete: function(html) {
text.set('html', html);
//alert(tree);
//eval(js);
},
onFailure: function() {
text.set('html', 'The Request has failed...');
}
});
$('frmNuovo_messaggio').addEvent('submit', function(event) {
new Event(event).stop();
alert("asdsdfsdfsdfsd");
posta.send($('frmNuovo_messaggio'));
/*
listbox_selectall('selDestinatario[]', true);
if ($('selDestinatario[]').length==0)
{
jAlert('Non stati specificato destinatari', 'Errore di invio');
return false;
}
if ($('txtMessaggio').value == "")
{
jAlert('Il testo del messaggio è vuoto', 'Errore di invio');
return false;
}
if ($('txtOggetto').value == "")
{
jConfirm('Il messaggio è privo di oggetto.
Inviare lo stesso?', 'Conferma invio', function(r) {
if (r)
{
$('txtDestinatario').value="(nessun oggetto)";
}
});
}
invia.send($('frmNuovo_messaggio'));
*/
});