GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes 'Undefined' Error with PHP and AJAX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark " Watch " New topic
Author

'Undefined' Error with PHP and AJAX

Matt James
Greenhorn

Joined: Jan 28, 2004
Posts: 22
Hi

Having problem with a simple AJAX call, I just keep getting an undefined error when I run this. I have checked the PHP file (getClassCodes.php) and that returns
data as it should, and I can see that working in the HTTP monitor in Netbeans, but when it goes to get the reponse - I just get 'undefined'.

Here is the simple PHP page:



and here is the JS file that I am using:



Please can anyone help.

kind regards

matt>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
What is undefined? Is there a JavaScript error?

What does the status and statusText say?

Have you used Firebug to figure out what is going on?


Eric
Matt James
Greenhorn

Joined: Jan 28, 2004
Posts: 22
Hi

That is the problem - it just says 'undefined' in the response. I will have a look at firebug if you think that it is useful.

kind regards

matt
Matt James
Greenhorn

Joined: Jan 28, 2004
Posts: 22
Status of 200 and a Status Text of OK - not sure what to do with Firebug - still just getting 'undefined' as the responseText.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Then it's likely a problem in your php.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Firebug lets you see the request go out and come back in the console if you enable it.

Eric

Matt James
Greenhorn

Joined: Jan 28, 2004
Posts: 22
I have spotted it - it is a typo in responseAjax - I have typed reponseText insteam of responseText.

That is several hours of my life that I won't get back

Never mind - and thanks for the heads up about Firebug, it looks quite useful
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
LOL, I stared at your code for spelling mistakes and somehow missed that.

Eric
 
GeeCON Prague 2014
 
subject: 'Undefined' Error with PHP and AJAX