尝试使用Ajax设置联系表单时出现以下错误:
send
v.extend.ajax
(anonymous function)
v.event.dispatch
o.handle.u
的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 );
如何解决这个问题的任何帮助都会很棒......
我对jQuery / Ajax很新。
答案 0 :(得分:0)
无需在ajaxComplete
success
的{{1}}回调中放置$.ajax()
。您还缺少一个右括号(}
)。
尝试以下方法:
(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);