File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Simple AJAX query what I'm missing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Simple AJAX query what I Watch "Simple AJAX query what I New topic
Author

Simple AJAX query what I'm missing?

raul saini
Greenhorn

Joined: May 18, 2010
Posts: 18
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

Joined: Aug 30, 2010
Posts: 147

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:


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
raul saini
Greenhorn

Joined: May 18, 2010
Posts: 18
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
you should set onreadystate BEFORE you send it!

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

You should be using jQuery to avoid these types of issues in the first place.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple AJAX query what I'm missing?