Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Responding to AJAX  RSS feed

 
Ashish Malik
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to generate options within <select> dynamically without refreshing page. Actualy its like when user changes product category, listed products get changed with AJAX help.
I created AJAX request and Servlet, but i get response as blank.

The AJAX script and servlet code are as below:

AJAX Script:



Servlet code:


Here lines 10-26 go perfect. I need to send string "send". It get generated perfectly. Problem is in sending the response.


I also need help about how to show options in page.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you used a tool such as Firebug to see what the response contains? If not, then you know what to do next.
 
Ashish Malik
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou you for introducing me to this wonderfull thing...god it would help me to debug servlet without bieng clueless!
but i checked the response its fine.

Now its something wrong in JavaScript...its not showing response.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's your problem:
request.onreadyStateChange = updatePage();

Carefully look at this statement. Is it doing what you intended? (Hint: it's not.)

This is just one of the many good reason to not write Ajax code by hand. Let a well-tested library such as jQuery do your Ajax for you.
 
Ashish Malik
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh man that was just-so-stupid mistake....
Thanks a lot!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!