Ciao a tutti,
ho un form che voiene compilato dall'utente e in base alle scelte effettuate restituisce un'immagine sulla stessa pagine. Per far ciò ho utilizzato AJAX. Ho però un problema sul controllo della risposta. Ho fatto questa funzione:
il problema è che alert(myReq.responseText); mi restituisce http://127.0.0.1/Sito/last.png però non mi entra nell'if e mi da l'alert con l'Attenzione.codice:function handleResponse(){ if(myReq.readyState == 4){ if(myReq.status == 200){ alert(myReq.responseText); if(myReq.responseText == 'http://127.0.0.1/Sito/last.png'){ img = document.getElementById('img'); img.src = myReq.responseText + "?a=" + Math.random().toString(); img.width = "640"; img.height = "430"; img.align = "right"; }else{ alert("Attenzione! Controllare la presenza del file .POS"); } }else{ alert("Niente da fare, AJAX non funziona "); } } }
Dove sbaglio?
grazie