我目前正在网站上工作...... 我遇到了一个错误...
我正在使用此邮件表单:
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 -->
但它没有发送任何电子邮件。有人可以帮忙吗?
答案 0 :(得分: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()
的文档答案 1 :(得分: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
});
答案 2 :(得分:0)
您必须将按钮的类型“按钮”更改为“提交”。