用ajax更改formspree的主题

时间:2016-09-29 16:57:12

标签: javascript angularjs ajax

我在角度应用中使用formspree。一切正常,但我似乎无法改变电子邮件的主题。

Html ......

([A-Za-z\.]+?):(.+?)(?=(?:[^\s]+:)|(?:$))

... JS

<form id="bookingForm" action="https://formspree.io/your@email.com"
  method="POST">
  <input type="text" name="{{client.name}}">
  <input type="{{client.email}}" name="_replyto">
  <input type="hidden" name="_subject" value="Request from {{client.name}}">
  <!-- some other info -->
  <input type="submit" value="Send">
</form>

_replyto似乎有效,但_subject却没有。

1 个答案:

答案 0 :(得分:0)

添加&#39; _subject &#39;发布请求并从主题输入字段中删除name属性:

$bookingForm = $('#bookingForm');
    $bookingForm.submit(function(e) {
    e.preventDefault();
    $.ajax({
        url: '//formspree.io/your@email.com',
        method: 'POST',
        data: {
            client: $scope.client.name,
            email: $scope.client.email,
            phone: $scope.client.phone,
            _subject: "Text here"
    },
    dataType: 'json',
 });
});