uc_payment.js should issue a GET with empty data

Project:Ubercart Contributions
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description
Project: 
Ubercart

script: payment/uc_payment/uc_payment.js
function get_payment_details(path)
version: Ubercart 6.x. 2.4

This function issues a $.post regardless whether there is data or not. A post with an empty body (and no content-length header field) can lead to 501 , 411 or 406 error return with mod_security. See also remark on lines 69 and 70 of misc/progress.js.

So it would be better to change the existing $.post call into a $.ajax call with a variable type (= HTTP method) and, additionally, with error handling to remove the progress bar in case of an error. This results in something like:

function get_payment_details(path) {
  ... // first 10 lines remain unchanged
  var data, method;
  if ($('#edit-payment-details-data').length) {
    data = { 'payment-details-data' : $('#edit-payment-details-data').val() };
    method = "POST";
  }
  else {
    data = {};
    method = "GET";
  }
  // Make the post to get the details for the chosen payment method.
  jQuery.ajax({
type: method,
url: path,
data: data,
success: function(details) {
      if (this_update.getTime() == payment_update) {
        // If the response was empty, throw up the default message.
        if (details == '') {
          $('#payment_details').empty().html(Drupal.settings.defPaymentMsg);
        }
        // Otherwise display the returned details.
        else {
          $('#payment_details').empty().append(details);
        }
      }

      // If on the order edit screen, clear out the order save hold.
      if (window.remove_order_save_hold) {
        remove_order_save_hold();
      }
    },
    error: function() {
        // If the response indicates an error, throw up the default message.
        $('#payment_details').empty().html(Drupal.settings.defPaymentMsg);
    }
  });
}

Version: 
Ubercart 2.x-dev
UK_Rogue's picture
Offline
Joined: 10/22/2010
Juice: 18
#1

This fixed all my progress bar issues (4 e-commerce sites) which got the problem after my host moved all my sites to a new server. So thank you! Can someone please ensure this patch is included in the new dev versions? There are a lot of people out there with this issue.