File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes send a form data using ajax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

send a form data using ajax

Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
how will send a form data using ajax.
when i click submit button request is not going at server.
i want to send request using data.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

It's be much easier, and a lot more robust, to use jQuery to do your Ajax. it not only makes the Ajax calls easier, it can gather the form data for you.

P.S. When you post code, make sure that it is properly indented.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
Bear Bibeault wrote:It's be much easier, and a lot more robust, to use jQuery to do your Ajax. it not only makes the Ajax calls easier, it can gather the form data for you.

P.S. When you post code, make sure that it is properly indented.



sorry Bear i don't know JQuery.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

You didn't know Java at one time either. Practically no one does Ajax "by hand" these days. There are too many nuances and pitfalls. If you are serious about your craft, you need to continue to learn new things and the best way to go about things.

But, if you want to continue on your current path, I'd recommend opening the debugging tools in the browser and stepping through the code to see where it's going awry.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

One of the best reasons for using jQuery is that it smooths out many of the warts in JavaScript. Since JavaScript is notorious for having critical differences between not only browsers, but browser versions, jQuery provides a way for coding more of a "write-once/run-anywhere" script without having to spend a lot of time and effort.


Customer surveys are for companies who didn't pay proper attention to begin with.
Anup Nadig Malathesha
Greenhorn

Joined: Jun 17, 2013
Posts: 6
Bear Bibeault wrote:It's be much easier, and a lot more robust, to use jQuery to do your Ajax. it not only makes the Ajax calls easier, it can gather the form data for you.

P.S. When you post code, make sure that it is properly indented.


Hi,
I used jQuery to send data from ajax to servlet. It was working fine when I was working on eclipse.
But when I tried to use these code on other server, I am getting 404 error.
I think this error is mainly because of unable to map my servlet class with the URL given in ajax.
I used web.xml in the eclipse but I also copied this file to server but it still not working.
Please help me regarding this.

Thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

Please do not post the same question more than once.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: send a form data using ajax
 
Similar Threads
Form validation using jsp and AJAX
struts-2 (set values to action class)
problem in servlet with Ajax
spaces while populating using s:iterator
How to call Servlet using AJAX