[英]Console error for jQuery/Ajax contact form
I've the following error when trying to set up a contact form using Ajax: 尝试使用Ajax设置联系表单时出现以下错误:
send
v.extend.ajax
(anonymous function)
v.event.dispatch
o.handle.u
jQuery jQuery的
( function($) {
$(document).ready(function() {
$("#get-contact-form").submit(function() {
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "http://ppplasmaltd.co.uk/templates/plasma/html/com_contact/contact/contact-form-process.php",
data: str,
success: function(msg) {
$(document).ajaxComplete(function(event, request, settings) {
if (msg === 'OK') {
result = '<div class="thanks" id="thanks">Thank you, we will reply <span>shortly.</span></div>';
else
{
result = msg;
}
});
}
});
return false;
});
});
} ) ( jQuery );
Any help on how to resolve this would be great.... 任何有关如何解决此问题的帮助都将很棒。
I'm fairly new to jQuery/Ajax. 我对jQuery / Ajax相当陌生。
There's no need to place ajaxComplete
inside your success
callback of $.ajax()
. 无需将ajaxComplete
放置在$.ajax()
success
回调中。 You also have a missing closing brace ( }
). 您还缺少一个右括号( }
。
Try the following: 请尝试以下操作:
(function($) {
$(document).ready(function() {
$("#get-contact-form").submit(function() {
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "http://ppplasmaltd.co.uk/templates/plasma/html/com_contact/contact/contact-form-process.php",
data: str,
success: function(msg) {
if (msg === 'OK')
{
result = '<div class="thanks" id="thanks">Thank you, we will reply <span>shortly.</span></div>';
}
else
{
result = msg;
}
}
});
return false;
});
});
}) (jQuery);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.