Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#15740 closed defect (fixed)

iframe.send (dojo/io and dojo/request) logic problems (method: "post")

Reported by: Karl Tiedt Owned by: Bryan Forbes
Priority: blocker Milestone: 1.8
Component: IO Version: 1.7.3
Keywords: Cc:
Blocked By: Blocking:

Description

Note: marked at 1.7.3 because that is where the original problem was found: provided below are also details regarding trunk

In the original iframe.send() code despite containing the documentation that reads:

//	method: String?
//		The HTTP method to use. "GET" or "POST" are the only supported
//		values.  It will try to read the value from the form node's
//		method, then try this argument. If neither one exists, then it
//		defaults to POST.

the logic for the method property ONLY defaults to post if you supply a form object (not covered in the documentation, in fact, it states it works just like other xhr* methods

//		All the properties described in the dojo.__ioArgs type, apply
//		to this type. The following additional properties are allowed
//		for dojo.io.iframe.send():

dojo/request carries over this same inconsistency... (w/o all the comments in its version of iframe.js) -- This problem goes away by simply passing in a vanilla form object... would it not make sense to patch the follow line

http://bugs.dojotoolkit.org/browser/dojo/dojo/trunk/request/iframe.js#L27

to:

formNode = dom.byId(options.form) || construct.create("form");

the lack of any default properties on the form will not override options.values... and it will all the proper assigning of method

Actually dojo/request actually does *nothing* if there is no formNode... while legacy iframe code would at least default to GET (despite documentation stating it would default to POST).

Change History (8)

comment:1 Changed 7 years ago by Karl Tiedt

Note: I just found out another caveat....

Not only does POST require a form object to be submitted with the iframe.send args but that form must also be attached to the DOM at some point or FF and IE will not properly submit the form to the iframe....

comment:2 Changed 7 years ago by Karl Tiedt

Apparently, IE also requires that method="post" be on the form, NOT specified in the send(args) -- sorry for the repeated posts but trying to provide as much info as possible so nobody else needs waste an entire day trouble shooting similar issues

Note: this is not because of dojo/request in particular, it just adopted/adapted code that wasnt well documented apparently which causes problems in the long run).

comment:3 Changed 7 years ago by Kenneth G. Franqueiro

Milestone: tbd1.8
Priority: undecidedblocker

Setting this to 1.8 / blocker as it hints at a regression in behavior of dojo/io/iframe now that it leans on dojo/request.

comment:4 Changed 7 years ago by Karl Tiedt

Per discussion with Bryan here is the minimal statement that does not work per documentation in 1.7.x and will not work in 1.8

// note: no form value passed in
iframe(url, {method:"POST", content: {prop: value}});

in 1.7.x this would result in GET despite the docs saying POST was default because no formNode (still incorrect) in 1.8 this would no-op (more incorrect)

What I learned throughout debugging this:

iframe POST requires the following statements to be true: 1) a form passed in to the iframe request 2) said form is attached to the DOM 3) said form has a name attribute set

The above things (not documented previously) would be nice to be handled by the iframe transport since... it cant work properly w/o these items being true.

comment:5 Changed 7 years ago by Bryan Forbes

In [29411]:

Fixes for request/iframe and io/iframe. refs #15740 !strict

comment:6 Changed 7 years ago by Bryan Forbes

In [29424]:

Fix request/iframe and io/iframe. refs #15740 !strict

  • request/iframe now always POSTs with .post()
  • io/iframe is backwards compatible with 1.7
  • Added tests

comment:7 Changed 7 years ago by Bryan Forbes

Resolution: fixed
Status: newclosed

comment:8 Changed 7 years ago by richso

still not work with <form> tag without method="post" in version 1.8.1, e.g.

<form id="myId" enctype="multipart/form-data">
....
</form>
<script>
dojo.io.iframe.send({url:'...', form:'myId', ...});
</script>
Version 0, edited 7 years ago by richso (next)
Note: See TracTickets for help on using tickets.