2016-09-29 4 views
2

私は角型アプリ内でformspreeを使用しています。私は電子メールの件名を変更することができないことを除いて、すべてが機能しています。ajaxでformspreeの件名を変更する

の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」を追加し、対象の入力フィールドからname属性を削除します。

$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', 
}); 
}); 
関連する問題