Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-10-2008, 12:14 AM   PM User | #1
Timmymna
New to the CF scene

 
Join Date: Mar 2008
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Timmymna is an unknown quantity at this point
Question Ajax Error Help

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

The tutorial 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:
Code:
Line: 9
Char: 1
Error: Object Expected
Code: 0
The code I used is:
PHP Code:
<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
Timmymna is offline   Reply With Quote
Old 03-10-2008, 08:35 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,689
Thanks: 158
Thanked 2,184 Times in 2,171 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Have you saved selectuser.js in the same directory?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 03-10-2008, 11:02 AM   PM User | #3
Timmymna
New to the CF scene

 
Join Date: Mar 2008
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Timmymna is an unknown quantity at this point
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
Timmymna is offline   Reply With Quote
Old 03-10-2008, 12:01 PM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,689
Thanks: 158
Thanked 2,184 Times in 2,171 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Well, the firefox's addon firebug is a best friend to find out the cause of such errors. BTW, I use Sajax toolkit, very easy to handle.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

Last edited by abduraooft; 03-10-2008 at 12:42 PM..
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
Timmymna (03-10-2008)
Old 03-10-2008, 12:29 PM   PM User | #5
Timmymna
New to the CF scene

 
Join Date: Mar 2008
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Timmymna is an unknown quantity at this point
Thumbs up

Installed firebug which gave me an error that led me to a couple of websites and solved the problem

I had to change:
PHP Code:
var xmlHttpfunction showUser(str)

to:
PHP Code:
var xmlHttp

function showUser(str)

Thanks for the help abduraooft
Timmymna is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:54 AM.


Advertisement
Log in to turn off these ads.