Jump to content
php.lv forumi

PHP, AJAX un IE


aika

Recommended Posts

ir input fields

  <input type="text" name="msg" size="16" id="msg" >
	 <button onclick="doWork();">⏎</button>

un funkcija:

  function doWork(){	
	 httpObject = getHTTPObject();
	 if (httpObject != null) {
		link = "chat/message.php?nick="+nickName+"&msg="+document.getElementById('msg').value;
		httpObject.open("GET", link , true);
		httpObject.onreadystatechange = setOutput;
		httpObject.send(null);
	 }
  }

message.php būtiskās rindas ir:

$f = fopen('msg.html',"a+");
$msg  = isset($_GET['msg']) ? htmlspecialchars($_GET['msg']) : ".";
fwrite($f,$line."\r\n");

 

uz FF viss ok, bet IE ievadot latviešu burtus rāda kvadrātus un citas muļķības!

piemēram š atgriež:�pan> utt

 

viss kods gan message.php nokodēts uz UTF-8

 

kādas idejas?

Link to comment
Share on other sites

nu nokodēt sanāk! Bet atpakaļ dabūt - nē!

kurā vietā es varu ielikt unescape?:

function doReload(){	
	 httpObject = getHTTPObject();
	 var randomnumber=Math.floor(Math.random()*10000);
	 if (httpObject != null) {
		link = "chat/message.php?all=1&rnd="+randomnumber;
		httpObject.open("GET", link , true);
		httpObject.onreadystatechange = setAll;
		httpObject.send(null);
	 }
  }

Link to comment
Share on other sites

setAll funkcijā, ja tā saņem datus atpakaļ no skripta.

 function setAll(){
	 if(httpObject.readyState == 4){
		var response = httpObject.responseText;
		var objDiv = document.getElementById("result");
		objDiv.innerHTML = response;
		objDiv.scrollTop = objDiv.scrollHeight;
	 }
  }

 

mēģināju gan var objDiv = unescape(document.getElementById("result"));

gan objDiv.innerHTML = unescape(response);

:( nepalīdz ...

ehh

Link to comment
Share on other sites

×
×
  • Create New...