Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events does not provide access to the response object #83

Closed
eximius313 opened this issue Nov 14, 2015 · 13 comments
Closed

events does not provide access to the response object #83

eximius313 opened this issue Nov 14, 2015 · 13 comments

Comments

@eximius313
Copy link

Events iron-form-error and iron-form-response don't provide access to the event.detail.response object.
While iron-form-error doesn't have it at all (it allows access only to the request), in iron-form-response event.detail.response is set to null.

@Typel
Copy link

Typel commented Nov 24, 2015

I think I've independently run into the same issue. Using both get and post methods, event.detail.response always returns null.
To verify that everything else was successful, response also includes:
event.detail.response: null
event.detail.aborted: false
event.detail.errored: false
event.detail.status: 200
event.detail.statusText: "OK"
event.detail.timedOut: false
event.detail.succeeded: true

iron-form is being submitted to a PHP script which simply echo's "Hello World".

Further details at StackOverflow

@Typel
Copy link

Typel commented Nov 25, 2015

This issue does not appear to affect json content types, which work normally.
I tested text and html content types and both returned null instead of the expected output.

DOCTYPE='application/json', iron-form.contentType='json' => non-null
DOCTYPE='text/plain', iron-form.contentType='text' => null
DOCTYPE='text/html', iron-form.contentType='html' => null

@cogero
Copy link

cogero commented Nov 25, 2015

I have the same problem, could you please fix this issue?

@ghost
Copy link

ghost commented Nov 26, 2015

+1

@albin-pawel
Copy link

same here ... +1

@jkosioreklemonsky
Copy link

+1 for response object for text/html

@notwaldorf
Copy link
Contributor

/cc @rictic, since iron-form is just using iron-ajax for submission

@eximius313
Copy link
Author

@rictic are there any chances of resolving this issue? I'd really appreciate this.

@jaromircelejewski
Copy link

hi,
any progress in solving this issue?

@nrei0
Copy link

nrei0 commented Jan 3, 2016

I tested on JSON, it returned null.

@rictic
Copy link
Contributor

rictic commented Feb 24, 2016

Hm, I'm having trouble reproducing this issue. Usually when response is unexpectedly null that's because the underlying iron-ajax has been configured to parse the response as JSON, but the response wasn't legal JSON. In that case the web platform is specced to set response to null.

Here's a repro case, comment out the handleAs line to see the response parsed as raw text rather than json: https://jsbin.com/mijuxocuho/edit?html,output

@eximius313
Copy link
Author

@rictic It works for you because https://httpbin.org/get?name=hi2 returns JSON.
as @Typel stated - in this particular case it works, but it does not work neither for text nor html.
iron-ajax should support not only JSON responses, so please reopen this issue.

@rictic
Copy link
Contributor

rictic commented Feb 25, 2016

It works for response types other than JSON, you just have to tell the underlying iron-ajax the response type to expect, as the response is parsed by the browser before javascript gets a hold of it.

Here's the above example, configured to treat the response type as text: https://jsbin.com/cajizisexu/edit?html,output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants