This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS 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
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

AJAX does not send data  RSS feed

 
Ranch Hand
Posts: 62
  • 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.



 
Marshal
Posts: 67255
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: 62
  • 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
Marshal
Posts: 67255
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: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
   Noting is changed

   And there is no errors in log.

   
 
Bear Bibeault
Marshal
Posts: 67255
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: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
   And developer console does not show any problems
 
Bear Bibeault
Marshal
Posts: 67255
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: 62
  • 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
Marshal
Posts: 67255
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: 62
  • 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....


 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!