• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ajax code getting null value

 
Kasparov Patel
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,
 
Eric Pascarello
author
Rancher
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
Rancher
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
Rancher
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
Rancher
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic