Jason Mayo Jason Mayo - 1 year ago 224
Ajax Question

502 Bad Gateway - jQuery / AJAX Form

I'm using the Ajax Form (http://malsup.com/jquery/form/) to submit a form I've created.

Locally, this works perfectly... But when I put it on the server, it's throwing this error in the console...

Failed to load resource: the server responded with a status of 502 (Bad Gateway) https://website.co.uk/shop/tents-by-brand/easy-camp

If I press the button a second time, I get this error

POST https://website.co.uk/shop/tents-by-brand/easy-camp 502 (Bad Gateway) jquery.min.js:4

Is it possibly something to do with the SSL / HTTPS?

My code looks like this:

function updateCart(data, statusText, xhr, $form) {
if (data.success) {
$("#notification-content").text('The item has been added to your basket');
$("#notification-content").text('Please wait... Adding item to basket.');

return true;

// Ajax Form Options

var ajaxFormOptions = {
success: updateCart,
dataType: 'json'

// Form Actions



var formId = $(this).parent('form').attr('id');
var formIdHash = '#' + formId;


console.log('Clicked = ' + formId);


Answer Source

I had the same issue. I ended up turning nginx off on my Plesk server to fix the issue.

To turn off nginx on a Plesk server:

Home > Tools Settings > Service Management > Stop Reverse Proxy (nginx)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download