• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

'Undefined' Error with PHP and AJAX

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67663
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then it's likely a problem in your php.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LOL, I stared at your code for spelling mistakes and somehow missed that.

Eric
 
Are we home yet? Wait, did we forget the tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic