• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Making a Post request using Ajax

 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I was trying to make a Post request using Ajax.
So, i wrote the below code(which i came across on the some useful website)

The crux of the code looked like


Now, i thought that passing the params was only optional, until i came to know that none of my request attributes were getting to me in the controller, only the parameters passed in the 'params' are obtained.
So, i thought of calling a javascript method on click on the required button that will populate the 'params' with all the name and value in the form in the form of "name1=value1&name2=value2";
but something doesnt seem correct.
Is this the expected behaviour?
Do we really need to fill in all the form data in the parameters to get them in the controller?
Why can the implementation be done in such a way that we directly obtain the parameters in the form, just like a normal submit(probably i am getting ahead of myself.. )

Thanks a lot.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because that is how it works. If you use a library such as JQuery, it can do it for you.

Eric
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric..
 
I am Arthur, King of the Britons. And this is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic