2

我目前正在一个网站上工作...我遇到了一个错误...

我正在使用此邮件表格:

jQuery(document).ready(function($){

// hide messages 
$("#error").hide();
$("#sent-form-msg").hide();

// on submit...
$("#contactForm #submit").click(function() {
    $("#error").hide();

    //required:

    //name
    var name = $("input#name").val();
    if(name == ""){
        $("#error").fadeIn().text("Name required.");
        $("input#name").focus();
        return false;
    }

    // email
    var email = $("input#email").val();
    if(email == ""){
        $("#error").fadeIn().text("Email required");
        $("input#email").focus();
        return false;
    }

    // web
    var web = $("input#web").val();
    if(web == ""){
        $("#error").fadeIn().text("Web required");
        $("input#web").focus();
        return false;
    }

    // comments
    var comments = $("#comments").val();

    // send mail php
    var sendMailUrl = $("#sendMailUrl").val();

    //to, from & subject
    var to = $("#to").val();
    var from = $("#from").val();
    var subject = $("#subject").val();

    // data string
    var dataString = 'name='+ name
                    + '&email=' + email        
                    + '&web=' + web
                    + '&comments=' + comments
                    + '&to=' + to
                    + '&from=' + from
                    + '&subject=' + subject;                                 
    // ajax
    $.ajax({
        type:"POST",
        url: sendMailUrl,
        data: dataString,
        success: success()
    });
});  


// on success...
 function success(){
    $("#sent-form-msg").fadeIn();
    $("#contactForm").fadeOut();
 }

return false;
});

我的页面上有这个:收集信息并将其转发到电子邮件地址。

<!-- form -->
            <form id="contactForm" action="#" method="post" />
                <fieldset>

                    <p>
                        <label for="name">Naam</label>
                        <input name="name" id="name" type="text" class="form-poshytip" title="Enter your full name" />
                    </p>

                    <p>
                        <label for="email">Email</label>
                        <input name="email" id="email" type="text" class="form-poshytip" title="Enter your email address" />
                    </p>


                    <p>
                        <label for="comments">Bericht</label>
                        <textarea name="comments" id="comments" rows="5" cols="20" class="form-poshytip" title="Enter your comments"></textarea>
                    </p>

                    <!-- send mail configuration -->
                    <input type="hidden" value="kai.zaper@gmail.com" name="to" id="to" />
                    <input type="hidden" value="Jebike EmailForm mail" name="subject" id="subject" />
                    <input type="hidden" value="send-mail.php" name="sendMailUrl" id="sendMailUrl" />
                    <!-- ENDS send mail configuration -->

                    <p><input type="button" value="Send" name="submit" id="submit" /> <span id="error" class="warning">Oeps, er is iets fout gegaan, probeer opnieuw.</span></p>
                </fieldset>

            </form>
            <p id="sent-form-msg" class="success">Uw email is verzonden.</p>
            <!-- ENDS form -->

但它没有发送任何电子邮件。有人可以帮忙吗?

4

3 回答 3

0

它似乎与$和冲突jQuery

宣布$.noConflict();

例子:

$.noConflict();
jQuery(document).ready(function($){

   // hide messages 
   $("#error").hide();
   ...
   ...
   ...
});

或者

使用这种方式

jQuery(document).ready(function(){
    // hide messages 
    jQuery("#error").hide();
    ...
    ...
    ...
});

或者这样

$(document).ready(function(){
    // hide messages 
    $("#error").hide();
    ...
    ...
    ...
});

请参阅有关jQuery.noConflict()的文档

于 2012-07-09T19:09:09.050 回答
0

尝试检查您的数据是否真的像这样发送到您的 php (只需取消注释成功功能并删除当前...):

  $.ajax({
  type:"POST", //php method
  url:'process.php',//where to send data...
  cache:'false',//IE FIX
  data: data,

 //check is data sent successfuly to your process.php
 //success:function(response){
 //alert(response)
 //}

success: function(){ //on success do something...

$('.success').delay(2000).fadeIn(1000);

//alert('THX for your mail!');
} //end sucess 
});
于 2012-07-09T19:16:42.093 回答
0

您必须将按钮的类型“按钮”更改为“提交”。

于 2016-12-18T22:03:59.303 回答