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

Allow XHR Submissions on forms #3483

Merged
merged 3 commits into from Jun 10, 2016
Merged

Conversation

mkhatib
Copy link
Contributor

@mkhatib mkhatib commented Jun 7, 2016

ITI: #3343

Writing some tests. Let me know if this looks good!

return;
}
if (this.xhrAction_) {
this.xhr_.fetchJson(this.xhrAction_, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to turn on credentials and requireAmpResponseSourceOrigin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mkhatib
Copy link
Contributor Author

mkhatib commented Jun 9, 2016

@cramforce @dvoytenko PTAL

/** @const @private {?string} */
this.xhrAction_ = this.form_.getAttribute('action-xhr');
if (this.xhrAction_) {
assertHttpsUrl(this.xhrAction_, this.form_, 'action-xhr');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before doing these checks, we need to resolve xhrAction_ to the full URL. Otherwise we can't test if it starts with https://... is not valid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we need to file against the cache/cdn:

  1. Resolve form[action] attribute to the absolute URL
  2. Resolve form[action-xhr] attribute to the absolute URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed.

@dvoytenko
Copy link
Contributor

LGTM with one fix requested.

@mkhatib mkhatib merged commit 68201a5 into ampproject:master Jun 10, 2016
@mkhatib mkhatib deleted the amp-form-xhr branch June 10, 2016 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants