Skip to main content

Bug Tracker

Side navigation

#5154 closed feature (invalid)

Opened September 01, 2009 04:21PM UTC

Closed April 16, 2011 08:34PM UTC

function for using post with load

Reported by: naktinis Owned by:
Priority: low Milestone:
Component: ajax Version: 1.4.3
Keywords: ajaxrewrite Cc: naktinis@gmail.com
Blocked by: Blocking:
Description

In order for load() method to submit data using post method, one needs to pass data object in the following form:

{'name1': 'value1', 'name2': ['value2', 'value3']} etc.

However, there is no easy way of getting this object for some form element.

Currently, I have written this function myself, but it would be nice to have it in the official release anyway.

It would be convenient to simply write:

$('box').load('path', $('#form').toObject()) or smth.

Attachments (0)
Change History (7)

Changed October 24, 2010 11:45PM UTC by rwaldron comment:1

priority: majorlow
resolution: → wontfix
status: newclosed

What you want to use is:

$('box').load('path', $('#form').serialize())

This will serialize the form input elements into key=value pairs for posting.

Changed October 26, 2010 06:51PM UTC by naktinis comment:2

Correct me if I'm wrong, but according to documentation "$('box').load('path', $('#form').serialize())" would issue GET command (the question is about issuing POST), because (quoting serialize, and load method documentations):

1. The .serialize() method creates a text string in standard URL-encoded notation.

1. The POST method is used if data is provided as an object; otherwise, GET is assumed.

See: http://api.jquery.com/serialize/ and http://api.jquery.com/load/

Changed October 26, 2010 11:30PM UTC by rwaldron comment:3

milestone: 1.41.5
resolution: wontfix
status: closedreopened
version: 1.3.21.4.3

I guess I didn't realize that it HAD to be a post. In that case, take a look at this:

http://richardwaldron.com/test-cases/5154.html

Changed November 22, 2010 06:23AM UTC by snover comment:4

blocking: → 7195
status: reopenedopen

Truly, the behaviour of $.fn.load is in a bizarre class of its own. Rather than providing a mechanism for switching between GET and POST, we should probably just revisit the logic of the method itself to begin with.

Changed December 27, 2010 10:37PM UTC by rwaldron comment:5

keywords: → ajaxrewrite

Changed January 01, 2011 08:32PM UTC by temp01 comment:6

_comment0: Replying to [ticket:5154 naktinis]: \ > However, there is no easy way of getting this object for some form element. \ \ There is: .serializeArray(). What you want is: \ \ $(..).load('url', $form.serializeArray()); \ \ That should do POST and work like the way you want.1293914059144168

Replying to [ticket:5154 naktinis]:

However, there is no easy way of getting this object for some form element.

There is: ''

.serializeArray()
''. What you want is:

$(..).load('url', $form.serializeArray());

That should do POST and work like the way you want.

Changed April 16, 2011 08:34PM UTC by john comment:7

resolution: → invalid
status: openclosed

Closing after temp01's feedback.