Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Ajax code getting null value

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I write JSP and Servlet in order to register user and onkeyup I am calling my ajax code which is validating whether userID is already register or not. My problem is that ajax code always getting null value for valid tag value and because of that it's showing always valid user ID. Please find my code as follow:

1. register.jsp



2. FormValidation.java


3. validateUserId.js


Can anyone help me? I had mark ajax code in red color where I am getting error.

Thanking You,
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you debugged what is coming from the server? Use a tool such as Fiddler or Firebug to watch the http requests. Is it sending the right data? Is it returning the right data?

Eric
 
Kasparov Patel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My servlet code firing query is ok. But I don't know why valid tag showing undefined. I have debug using crome developer tool.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well the responseXML should be read off the root



You also have to be carefule of using firstChild since whitepspace is known to cause issue with browsers.

Eric
 
Kasparov Patel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried what you have suggested but getting same following error


Unable to get value of the property 'getElementsByTagName': object is null or undefined
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what does xmlMessage show?



If it is null, that means your xml is not valid.

Eric
 
Kasparov Patel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Getting following error


SCRIPT5007: Unable to set value of the property 'value': object is null or undefined
validateUserId.js, line 54 character 13
LOG: [object]
SCRIPT5007: Unable to set value of the property 'value': object is null or undefined
validateUserId.js, line 54 character 13
LOG: [object]
SCRIPT5007: Unable to set value of the property 'value': object is null or undefined
validateUserId.js, line 54 character 13
LOG: [object]
SCRIPT5007: Unable to set value of the property 'value': object is null or undefined
validateUserId.js, line 54 character 13
LOG: [object]
SCRIPT5007: Unable to set value of the property 'value': object is null or undefined
validateUserId.js, line 54 character 13
LOG: [object]
SCRIPT5007: Unable to set value of the property 'value': object is null or undefined
validateUserId.js, line 54 character 13
LOG: [object]
SCRIPT5007: Unable to set value of the property 'value': object is null or undefined
validateUserId.js, line 54 character 13
LOG: [object]
SCRIPT5007: Unable to set value of the property 'value': object is null or undefined
validateUserId.js, line 54 character 13
SCRIPT5007: Unable to get value of the property 'firstChild': object is null or undefined
validateUserId.js, line 44 character 9
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you have more than one bug.

fanme

Eric
 
Kasparov Patel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had corrected that typo error. Thanks for your help. Now it's working.
 
Fire me boy! Cool, soothing, shameless self promotion:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic