PDA

View Full Version : Ajax Error Help


Timmymna
03-10-2008, 01:14 AM
I have just started learning about Ajax today and was working through some examples online. I have come across a very simple one that I just can't get to work:confused:

The tutorial (http://www.w3schools.com/php/php_ajax_database.asp) I have copied the code from.

When I choose from the drop down box nothing happens I get an error icon in the corner. It states:
Line: 9
Char: 1
Error: Object Expected
Code: 0

The code I used is:
<html>
<head>
<script src="selectuser.js"></script>
</head>
<body><form>
Select a User:
<select name="users" onchange="showUser(this.value)">
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Glenn Quagmire</option>
<option value="4">Joseph Swanson</option>
</select>
</form><p>
<div id="txtHint"><b>User info will be listed here.</b></div>
</p></body>
</html>

If anyone can point me in the right direction, thanks:D

abduraooft
03-10-2008, 09:35 AM
Have you saved selectuser.js in the same directory?

Timmymna
03-10-2008, 12:02 PM
Thanks for your reply, yeah selectuser.js is in the same directory.
I have also tried copying the contents of selectuser and putting it in the html file but I still get the same error.

Could it be something to do with the server side of things as I'm using one I've setup and may have missed something trivial:confused:

abduraooft
03-10-2008, 01:01 PM
Well, the firefox's addon firebug (http://addons.mozilla.org/firefox/addon/1843) is a best friend to find out the cause of such errors. BTW, I use Sajax toolkit (http://www.modernmethod.com/sajax/), very easy to handle.

Timmymna
03-10-2008, 01:29 PM
Installed firebug which gave me an error that led me to a couple of websites and solved the problem :)

I had to change:
var xmlHttpfunction showUser(str)
{
to:
var xmlHttp

function showUser(str)
{

Thanks for the help abduraooft :thumbsup: