This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Ajax code getting null value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax code getting null value " Watch "Ajax code getting null value " New topic
Author

Ajax code getting null value

Kasparov Patel
Ranch Hand

Joined: Jan 23, 2012
Posts: 40
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jan 23, 2012
Posts: 40
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jan 23, 2012
Posts: 40
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
what does xmlMessage show?



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

Eric
Kasparov Patel
Ranch Hand

Joined: Jan 23, 2012
Posts: 40
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Looks like you have more than one bug.

fanme

Eric
Kasparov Patel
Ranch Hand

Joined: Jan 23, 2012
Posts: 40
I had corrected that typo error. Thanks for your help. Now it's working.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax code getting null value
 
Similar Threads
html form,servlet
Communicate with the server without a browser.
Jquery form validation
how to keep register page data if register fails
Values from serialize are all null