Opened 13 years ago
Closed 12 years ago
#5154 closed feature (invalid)
function for using post with load
Reported by: | naktinis | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | ajax | Version: | 1.4.3 |
Keywords: | ajaxrewrite | Cc: | [email protected]… |
Blocked by: | Blocking: | #7195 |
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.
Change History (7)
comment:1 Changed 12 years ago by
Priority: | major → low |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
comment:2 Changed 12 years ago by
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):
- The .serialize() method creates a text string in standard URL-encoded notation.
- 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/
comment:3 Changed 12 years ago by
Milestone: | 1.4 → 1.5 |
---|---|
Resolution: | wontfix |
Status: | closed → reopened |
Version: | 1.3.2 → 1.4.3 |
I guess I didn't realize that it HAD to be a post. In that case, take a look at this:
comment:4 Changed 12 years ago by
Blocking: | 7195 added |
---|---|
Status: | reopened → open |
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.
comment:5 Changed 12 years ago by
Keywords: | ajaxrewrite added |
---|
comment:6 Changed 12 years ago by
Replying to 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.
comment:7 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | open → closed |
Closing after temp01's feedback.
What you want to use is:
$('box').load('path', $('#form').serialize())
This will serialize the form input elements into key=value pairs for posting.