LeRoy
10-09-2007, 11:29
salve a tutti!
Da poco ho deciso di arricchire le mie pagine web con ajax e mi sono subito arenato su un problema;le funzioni javascript per la gestione in ajax sono queste:
function createXMLHttpRequest()
{
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function getNote(element) {
createXMLHttpRequest();
var url = "modules.php?op=modload&name=assistenza&file=note&key_note=" + escape(element.id);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = handleNote(element.id);
xmlHttp.send(null);
}
function handleNote(note_id)
{
if (xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)
{
setNote(xmlHttp.responseXML);
}
}
}
function setNote(courseNote) {
var id_nota = courseNote.getElementsByTagName("id_nota")[0].firstChild.data;
var data_get = courseNote.getElementsByTagName("data")[0].firstChild.data;
//document.getElementById("div_3").innerHTML = xmlHttp.responseText;
alert("notA4:"+ id);
}
sostanzialmente quando l'utente clicca su una nota viene eseguita la funzione getNote alla quale viene passato un id e questo permette attraverso AJAX di fare una query su db e ricavare informazioni aggiuntive. Il problema è che non riesco a passare l'id immesso dall'utente alla funzione setNote: se eseguo il questo comando
function handleNote(note_id) {
alert("ID: "+note_id);
if (xmlHttp.readyState == 4){
if (xmlHttp.status == 200){
setNote(xmlHttp.responseXML);
}
}
}
mi visualizza correttamente l'id,altrimenti se l'alert lo eseguo dentro l'if:
function handleNote(note_id) {
if (xmlHttp.readyState == 4){
if (xmlHttp.status == 200){
alert("ID: "+note_id);
setNote(xmlHttp.responseXML);
}
}
}
non mi fa nulla:(
Da poco ho deciso di arricchire le mie pagine web con ajax e mi sono subito arenato su un problema;le funzioni javascript per la gestione in ajax sono queste:
function createXMLHttpRequest()
{
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function getNote(element) {
createXMLHttpRequest();
var url = "modules.php?op=modload&name=assistenza&file=note&key_note=" + escape(element.id);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = handleNote(element.id);
xmlHttp.send(null);
}
function handleNote(note_id)
{
if (xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)
{
setNote(xmlHttp.responseXML);
}
}
}
function setNote(courseNote) {
var id_nota = courseNote.getElementsByTagName("id_nota")[0].firstChild.data;
var data_get = courseNote.getElementsByTagName("data")[0].firstChild.data;
//document.getElementById("div_3").innerHTML = xmlHttp.responseText;
alert("notA4:"+ id);
}
sostanzialmente quando l'utente clicca su una nota viene eseguita la funzione getNote alla quale viene passato un id e questo permette attraverso AJAX di fare una query su db e ricavare informazioni aggiuntive. Il problema è che non riesco a passare l'id immesso dall'utente alla funzione setNote: se eseguo il questo comando
function handleNote(note_id) {
alert("ID: "+note_id);
if (xmlHttp.readyState == 4){
if (xmlHttp.status == 200){
setNote(xmlHttp.responseXML);
}
}
}
mi visualizza correttamente l'id,altrimenti se l'alert lo eseguo dentro l'if:
function handleNote(note_id) {
if (xmlHttp.readyState == 4){
if (xmlHttp.status == 200){
alert("ID: "+note_id);
setNote(xmlHttp.responseXML);
}
}
}
non mi fa nulla:(