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
For starters, your
getEmployee()function shouldreturn 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.