• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

how to write ajax to servlet

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sir
I a have the following code kindly tell me what to do,
the responce is not comming when I am entering data to text box,servlet should give the rescponse
I am using web Logic server.
Html file



Servelt file

 
Ranch Hand
Posts: 35
Hibernate jQuery Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pradipta kumar rout wrote:

function handleSearchSuggest()
{
if (searchReq.readyState == 4)
{
var str = searchReq.responseText;
}
}

document.getElementById('search_suggest').innerHTML =str;



variable str dosent looks to be in the scope.
 
pradipta kumar rout
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you ,

Sir I am new to ajax this is my first program on ajax kindly tell me whether a server is required or no I am using web logic server..
what to write in the url part of following code,If web server is required then or if not required then kindly tell me what to write ,
I know the servlet name but kindly give an example

searchReq.open("POST",'suggest_servlet2', true);


or only html file and servlet file will do the job ..
 
pradipta kumar rout
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you ,

Sir I am new to ajax this is my first program on ajax kindly tell me whether a server is required or no I am using web logic server..
what to write in the url part of this following code,

Kindly tell me if server is required then what to write and if not required then what to write.
I know that is the servlet name but how to write that
kindly give me one example..

searchReq.open("POST",'suggest_servlet2', true);


or only html file and servlet file will do the job ..
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pradipta...

It will be nice if you can use

searchReq.onreadystatechange=handleSearchSuggest;
searchReq.open("Get",url,true);

instead of

searchReq.open("POST",'suggest_servlet2', true);
searchReq.onreadystatechange = handleSearchSuggest;
...

I tried my perfectly running example using your code and i too didn't get the result ....
but i am getting the result with the above code...

I think it will solve it...

And i don't know much but if it is ajax then why do you need to POST the arguements..... as no one can see the aruguments flowing from one page to another.....

Thanks
 
Rupesh Mhatre
Ranch Hand
Posts: 35
Hibernate jQuery Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pradipta kumar rout wrote:
Sir I am new to ajax this is my first program on ajax kindly tell me whether a server is required or no I am using web logic server..



AJAX is very easy and useful thing to have in your bag. Please go through this. This will give you basic introduction of AJAX.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Ranch, Vipin Gandhi!

Vipin Gandhi wrote:And i don't know much but if it is ajax then why do you need to POST the arguements...


POST is used specially when sending large amount of data to the server as GET has size limitation.

pradipta kumar rout wrote:...kindly tell me whether a server is required or no I am using web logic server..


Yes you need a Web server, where your servlets/JSP etc... reside so that you can send the request and get a response. Go through the link provided by Rupesh Mhatre above to get the basics right.
 
reply
    Bookmark Topic Watch Topic
  • New Topic