2016-09-29 44 views
2

我在角度应用中使用了formspree。除了我似乎无法改变电子邮件的主题外,一切都在运作。用ajax改变formpree的主题

HTML ...

<form id="bookingForm" action="https://formspree.io/[email protected]" 
    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> 

JS ...

$bookingForm = $('#bookingForm'); 
$bookingForm.submit(function(e) { 
e.preventDefault(); 
$.ajax({ 
    url: '//formspree.io/[email protected]', 
    method: 'POST', 
    data: { 
    client: $scope.client.name, 
    email: $scope.client.email, 
    phone: $scope.client.phone, 
    // some other info 
    }, 
    dataType: 'json', 
}); 
}); 

的_replyto似乎是工作,但_subject不是。

回答

0

添加“_subject”你的POST请求并从主题输入字段的名称属性:

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