我试图通过将数据发送到php脚本来创建联系表单,以便从sammy.js应用程序中的表单发送邮件。我把它设置如下,它不起作用。任何人都可以解释为什么并让我正确的方向来解决它?谢谢!
html表格:
<form class="form-horizontal" action="#/submitcontact">
<fieldset>
<div class="control-group">
<label class="control-label" for="input01">Your Name:</label>
<div class="controls">
<input type="text" class="input-xlarge" id="from-name">
<p class="help-block">Nice to know who the message is from.</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="input01">Your Email:</label>
<div class="controls">
<input type="text" class="input-xlarge" id="from-email">
<p class="help-block">Supply an email so I can reply.</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="input01">Your Message:</label>
<div class="controls">
<textarea class="input-xlarge" id="from-msg"></textarea>
<p class="help-block">Including a message is always nice.</p>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn" style="position:relative;float:center;">Send!</button>
</div>
</div>
</div>
</fieldset>
</form>
将其提交到路线#/ submitcontact:
this.post('#/submitcontact', function(context) {
$.post("mail.php", this.params,
function(data) {
alert("Data Loaded: " + data);
});
});
答案 0 :(得分:0)
尝试将每个值传递给功能帖子。像这样修改代码:
context = $('form').serialize();
$.post('#/submitcontact', function(context) {
$.post("mail.php", this.params,
function(data) {
alert("Data Loaded: " + data);
});
});
也许这可行。