Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Simple AJAX query what I'm missing?

 
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.
 
Ranch Hand
Posts: 147
Eclipse IDE Tomcat Server Debian
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should set onreadystate BEFORE you send it!

Eric
 
Marshal
Posts: 67463
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic