2016-09-29 23 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', 
}); 
});