All pastes #252894 Raw Edit

ajax-issue

public text v1 · immutable
#252894 ·published 2006-11-20 01:58 UTC
rendered paste body
/--------------------------------problem----------------------------------/
I'm trying to use ajax so that when you click on a thumbnail, the full image
will appear, with some text as byline - both image and text is gotten from a
database. All works well and nice, the image is shown, as is the text - HOWEVER:
If I have å ä ö in the text, those chars get replaced by ?.

I've read through some documentation on escape(), unescape(), encodeURI(), decodeURI() 
but haven't been able to get it to work despite that. What am I doing wrong?

Any help would be greatly appreciated!
Thanks!


/------------code in file which gets the info to display------------------/
<?php
	include("../databaseconnector.php");
	$bild_id = $_GET['id'];
	$sql = mysql_query("SELECT foto_id,bildtext,owner FROM foto WHERE id='$bild_id'") or die(mysql_error());
	$r = mysql_fetch_array($sql);

	echo "<img src='../a/".$r[2]."/img_main/main_id".$r[0]."'>";
	echo "<br />".$r[1];
?>


/----------------------------------ajax code------------------------------/
....snip....
var http = getXMLHTTPRequest();

function getServerText(image_id)
{
	var myurl = 'incl/fotoalbum_center_bild.php?id=';
	myRand = parseInt(Math.random()*999999999999);
	var modurl = myurl+image_id+"&rand="+myRand;
	http.open("GET", modurl, true);
	http.onreadystatechange = useHttpResponse;
	http.send(null);
}

function useHttpResponse()
{
	if(http.readyState == 4)
	{
		if(http.status == 200)
		{
			var mytext = http.responseText;
			document.getElementById('myPageElement').innerHTML = mytext;
		}
	}
	else
	{
		document.getElementById('myPageElement').innerHTML = "";
	}
}
....snip....