This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

'Undefined' Error with PHP and AJAX

 
Matt James
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then it's likely a problem in your php.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firebug lets you see the request go out and come back in the console if you enable it.

Eric

 
Matt James
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL, I stared at your code for spelling mistakes and somehow missed that.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic