简体   繁体   English

如何与聚合物一起使用ajax形式?

[英]How use ajax-forms with polymer?

I'm trying to create a simple web app using polymer. 我正在尝试使用聚合物创建一个简单的Web应用程序。

I have an email, name and checkbox field for the user. 我有该用户的电子邮件,名称和复选框字段。

What I would like to do is when the user enters their information into these inputs, the data is stored and sent to me. 我想做的是,当用户将他们的信息输入到这些输入中时,数据被存储并发送给我。

I understand this may be a novice question, but I am finding difficulty to get this to work with the Polymer framework. 我知道这可能是一个新手问题,但是我发现很难将其与Polymer框架一起使用。

Below is my code. 下面是我的代码。 HTML 的HTML

<paper-input-decorator id="decorator" label="{{label}}" floatinglabel="{{floatingLabel}}" value="{{value}}" disabled?="{{disabled}}">
    <input is="core-input" value="{{value}}" committedvalue="{{committedValue}}" on-change="{{changeAction}}" method="post" disabled?="{{disabled}}">
  </paper-input-decorator>

HTML 的HTML

<link rel="import" href="../../bower_components/ajax-form/ajax-form.html">
<link rel="import" href="../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../../bower_components/paper-input/paper-input.html">

<form id="doSomethingForm" is="ajax-form" action="/api/doSomething" method="post">
    <paper-input label="Name" type="text" name="name"></paper-input>
    <paper-input label="Email" type="text" name="email"></paper-input>
    <paper-button id="submitButton" raised on-tap="{{submit}}">Submit</paper-button>
</form>

Javascript Java脚本

Polymer({
    submit: function() {
        this.$.doSomethingForm.submit();
    }
});

This will send a POST call to your server on endpoint /api/doSomething with parameters name and email 这将通过参数nameemail将POST调用发送到端点/api/doSomething上的服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM