File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes JQuery:  Problem with $(this).find('input'). serialize() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JQuery:  Problem with $(this).find( Watch "JQuery:  Problem with $(this).find( New topic
Author

JQuery: Problem with $(this).find('input'). serialize()

Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 635
Hi,

I have following code in Html,Js and JSP followed by weird out put of jsp, can some kindly let me know whats wrong with any of the file?
====== ===== ============ ======== HTML ========= ======== ========

====== ====== ======= ======= ===== JS ======= ======= ===========

===== ==== ========= ======= ====== JSP ===== ==== ========== ======



========== ====== ===========

out put ======================


If i uncomment js code in file then the alerts show me correct names of input field.


-Praful
[ April 21, 2008: Message edited by: Praful Thakare ]

All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 635
okay,did some rnd and found the pattern of this weird behavior, serialize method is converting each char of parameter and value in to one separate request parameter value pair. i kept only one input with name term and value as praful, so instead of passing it as term=praful it is passed as

Bear, what are your thoughts?

-P
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

Your issue is with the data parameter that you are passing to the load() method:



That param is expected to be an object hash of the parameters to send with the request. The serialize() method returns a query string of the params (which is useful when setting the post body of request, but not here), so the string is being parsed into its separate characters for sending as the prams. Not what you want.

You want to use the serializeArray() method which returns an object hash suitable for use with load():


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 635
You The Man Bear, its working now.

It also runs without any method only difference in this case it also send submit button as request parameter and in case of serializeArray it does not send submit button.

Also, does load method not use Post for sending form data?


-P
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

If I recall correctly, load() always uses a GET.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 635
ah, okay..i am exploring the jQuery pulgins now, may be there is better way to submit form for Ajax request.

-P
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

Check out the official jQuery Form Plugin.

It makes easy to instrument a form to submit itself through Ajax.

For example:



will automatically cause the form to submit itself as an Ajax request when submitted.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 635
awesome !!! thanks much, I am so glad I followed your suggestion to choose JQuery, enjoying exploring it.

-P
[ April 23, 2008: Message edited by: Praful Thakare ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JQuery: Problem with $(this).find('input'). serialize()