1

我试图通过将数据发送到 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);
            });
        });
4

1 回答 1

0

Try passing each value to function post. Modify the code like this:

context = $('form').serialize();
$.post('#/submitcontact', function(context) {
            $.post("mail.php", this.params,
                function(data) {
                    alert("Data Loaded: " + data);
            });
        });

Maybe this could work.

于 2012-04-28T22:43:28.340 回答