Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple AJAX query what I'm missing?

 
raul saini
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using Ajax after an year...please tell me what I'm missing:

JSP/Ajax File



Servlet:


I'm getting a null pointer exception in Servlet at line 27:


Probably the way I'm using xmlhttp.send(queryString); in JavaScript is wrong, but not able to figure out.
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using GET, don't you need to embed the query string in the URL?

I believe you use the "send(queryString)" function when you're doing a POST. Similarly, the "application/x-www-form-urlencoded" content-type is only needed when sending POST data.

Try:
 
raul saini
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pete Nelson wrote:If you're using GET, don't you need to embed the query string in the URL?

I believe you use the "send(queryString)" function when you're doing a POST. Similarly, the "application/x-www-form-urlencoded" content-type is only needed when sending POST data.

Try:


Even if I'm using POST, it is giving the same error.
--EDIT... GOT it done...thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should set onreadystate BEFORE you send it!

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be using jQuery to avoid these types of issues in the first place.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic