我正在使用 Ajax 表单 ( http://malsup.com/jquery/form/ ) 提交我创建的表单。
在本地,这工作得很好......但是当我把它放在服务器上时,它会在控制台中抛出这个错误......
加载资源失败:服务器响应状态为 502 (Bad Gateway) https://website.co.uk/shop/tents-by-brand/easy-camp
如果我第二次按下按钮,我会收到此错误
POST https://website.co.uk/shop/tents-by-brand/easy-camp 502(坏网关)jquery.min.js:4 发送 f.extend.ajax $.fn.ajaxSubmit doAjaxSubmit f.event。调度 h.handle.i
这可能与 SSL / HTTPS 有关吗?
我的代码如下所示:
function updateCart(data, statusText, xhr, $form) {
if (data.success) {
$("input[name=XID]").val(data.XID);
$('.cart-total').html(data.cart_total);
$("#notification-content").text('The item has been added to your basket');
$("#notification-alt").delay(2000).fadeOut(
500,
function(){
$("#notification-content").text('Please wait... Adding item to basket.');
}
);
}
return true;
}
// Ajax Form Options
var ajaxFormOptions = {
success: updateCart,
dataType: 'json'
}
// Form Actions
$(".cart-submit-button").click(function(event){
$("#notification-alt").fadeIn(500)
var formId = $(this).parent('form').attr('id');
var formIdHash = '#' + formId;
$(formIdHash).ajaxForm(ajaxFormOptions);
console.log('Clicked = ' + formId);
});