• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

AJAX does not send data  RSS feed

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
   Greetings to all!

    Code in JSP:


 In Servlet




   But ajax does not  fulfil post method.



 
Sheriff
Posts: 67257
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One problem I see (besides the code formatting which is all over the place) is that you are not stopping the default action of the form submission. If you want to make an Ajax call rather than actually submitting the form, you either need to call the preventDefault method of the event, or return false from the event handler.

Why aren't you using jQuery to do all this? Makes it tons easier.
 
Andrey Dmitriev
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:One problem I see (besides the code formatting which is all over the place) is that you are not stopping the default action of the form submission. If you want to make an Ajax call rather than actually submitting the form, you either need to call the preventDefault method of the event, or return false from the event handler.




   To make is so, for example?




Why aren't you using jQuery to do all this? Makes it tons easier.



  Yes, i'll try it later
 
Bear Bibeault
Sheriff
Posts: 67257
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So now, the page will not submit as you have blocked that. How does the behavior change? Use the network tab in DevTools to see if any request is being generated. Any errors in the console log?
 
Andrey Dmitriev
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
   Noting is changed

   And there is no errors in log.

   
 
Bear Bibeault
Sheriff
Posts: 67257
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the Networking Panel show that a request is generated?
 
Andrey Dmitriev
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
   And developer console does not show any problems
 
Bear Bibeault
Sheriff
Posts: 67257
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Does the Networking Panel show that a request is generated?

 
Andrey Dmitriev
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Bear Bibeault wrote:Does the Networking Panel show that a request is generated?




 Failed to load resource: the server responded with a status of 404 ()
 
Bear Bibeault
Sheriff
Posts: 67257
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That likely means your URL is malformed. What happens when you try to load that URL directly into the browser?

Also, why is your URL absolute, versus server-relative? You could run into CORS issues.
 
Andrey Dmitriev
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:That likely means your URL is malformed. What happens when you try to load that URL directly into the browser?



  When I try to load that URL directly into the browser  In Safari this URL forwards me on correctly page.   But, doing this in Chrome, i get the empty page...


Bear Bibeault wrote:Also, why is your URL absolute, versus server-relative? You could run into CORS issues.



      I have used relative URL in AJAX, but withot success.  

But in html-form-submit it works properly: for example


    I'm confused....


 
sunglasses are a type of coolness prosthetic. Check out the sunglasses on this tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!