tags:

views:

131

answers:

3

Hello,

I am using the following html page:

<html>

<head>

<title>AJAX Example</title>

<meta http-equiv="Content-Type" content="text/html"; charset="iso-8859-1">

</head>

<script language="JavaScript" src="ajaxlib.js"></script>

<!--define the ajax javascript library-->

<body>

Click this <a href="#" OnClick="GetEmployee()">link</a> to show ajax

content (will be processed backgroundly without

refreshing whole page)<br/>

<!--a href=# OnClick=GetEmployee() is the javascript event on a

link to execute javascript function (GetEmployee) inside ajaxlib.js-->

<div id="Result">< the result will be fetched here ></div>

<!--javascript use GetElementById function to replace the data

backgroundly, we use <div> tag with  id Result here so javascript

can replace this value-->

</body>

</html>

The Javascript is here: http://www.nomorepasting.com/getpaste.php?pasteid=22046

And the PHP is here: http://www.nomorepasting.com/getpaste.php?pasteid=22047

The problem is, everything seems logical and there are no errors, but the javascript does not seem to be called, and calling the php file directly gives a result such as this:

                                                   

Well the characters will not even paste in apparently...., but lots of little boxes with like this:

10
01

+1  A: 

I suggest getting Firefox + tamper data add-on.. You'll be able to see if your browser is downloading the javascript, and also view the ajax request + data to see what's going on. Also checkout the error console for javascript errors. I would start there.

DreamWerx
+2  A: 

For starters, your getEmployee() function should return false; to prevent the default action on the <a>. The little boxes thing seems to imply that the character sets aren't matching up. Make sure that the HTML page and the PHP page both use the same character set. I'd suggest trying to make everything UTF-8.

Edit: misread slightly - I think it's the character set PHP is outputting doesn't match the character set in your database.

Greg
Ahhh...why would that matter? I tried changing stuff with iconv, but quotes and things went missing.
Joshxtothe4
The little 10/01 things are characters that firefox doesn't know how to display. If you're telling it (via your HTTP headers) that a document is in one charset when it's actually in another (or even part of the document is in another) then it's going to get very confused.
Greg
Is there a way to easily convert charsets without losing information?
Joshxtothe4
+1  A: 

Look up Firefox Firebug extension, very helpful with this.