W Pliku .php generuje dokument XML. Wygląda on mniej-wiecej tak:
Kod
<response>
<option id="1">tresc</option><option id="2">tresc</option><option id="3">tresc</option><option id="4">tresc</option><option id="5">tresc</option>
</response>
<option id="1">tresc</option><option id="2">tresc</option><option id="3">tresc</option><option id="4">tresc</option><option id="5">tresc</option>
</response>
wszystkie <option></option> sa wziete w htmlentities .
funkcja w JS :
Kod
function processHandleServerResponse()
{
if(xmlHttp.readyState ==4)
{
if(xmlHttp.status == 200)
{
xmlResponse = xmlHttp.responseXML;
xmlDocumentElement = xmlResponse.documentElement;
returnMessage = xmlDocumentElement.firstChild.data;
document.getElementById("unit1").innerHTML = returnMessage;
}
}
}
{
if(xmlHttp.readyState ==4)
{
if(xmlHttp.status == 200)
{
xmlResponse = xmlHttp.responseXML;
xmlDocumentElement = xmlResponse.documentElement;
returnMessage = xmlDocumentElement.firstChild.data;
document.getElementById("unit1").innerHTML = returnMessage;
}
}
}
W firefoxie i iceweaselu wszystko działa OK. Problem pojawia sie w konquerorze, czy internet explorerze - te przegladarki ignoruja znaczniki html nawet po przejsci htmlentities.
Jak to ominąć ? Moge wprowadzic pewne zmiany, ale chodzi ogólnie o to aby do el. "unit1" dopisac tekst (czyli pola option) wygenerowane w pliku .php . Odrazu zaznacze ze id w option jest przydzielane w pliku .php na podstawie wpisu w bazie danych
Ok. już sobie z tym poradziłem.
Kod
function processHandleServerResponse()
{
if(xmlHttp.readyState ==4)
{
if(xmlHttp.status == 200)
{
response = xmlHttp.responseText;
document.getElementById("TYPE_ID").innerHTML = response;
}
}
}
{
if(xmlHttp.readyState ==4)
{
if(xmlHttp.status == 200)
{
response = xmlHttp.responseText;
document.getElementById("TYPE_ID").innerHTML = response;
}
}
}
W pliku .php mogłem usunąć htmlentities oraz znaczniki <response>.
Aby zachować poprawne kodowanie wystarczyło że dodałem :
Kod
header('Content-Type: text/html; charset=iso-8859-2');
Na początku pliku .php