Search code examples
javascriptjquerycoldfusion-9

JQuery function stops fetching data when trying to submit large amount of parameters


Run Coldfusion 9 on Windows 2008 R2 Server.

I have a cfm page with multiple dropdowns (some are cfselect) and dynamically generated lists of checkboxes interdependent on each other. I am using JQuery to submit data to cfc functions and to display data.

It was all working fine until we added new company with large number of records. This translated into large URL query string with a lot of parameters submitted for processing. That's when we started to have problems. I noticed when trying to directly submitting URL, if the total number of characters in URL is more than 2114 I get an error status code 302 Redirect and nothing is displayed.

I tried to play with postParametersLimit and postSizeLimit increasing to 1000.0 in neo-runtime.xml and restarting server but, this did not help.

Below is jquery function:

function populateBills(){
var plID;

if ($('#planenrolldate_id').val() == undefined)
  plID = $('input[name=planenrolldate_id]').val();
else
  plID = $('#planenrolldate_id').val();

var sID = $('#sponsor_id').val(); 
var pID = $('#plan_id').val();

var fromMonth = $('#from_month').val();
var fromYear = $('#from_year').val();
var toMonth = $('#to_month').val();
var toYear = $('#to_year').val();

$.ajax({
  type:"POST",
 url:"../components/billing/custompremstatus.cfc?method=GetBillsArr&planenrolldate_id=" + plID + "&sponsorid=" + sID + "&fM=" + fromMonth + "&fY=" + fromYear + "&tM=" + toMonth + "&tY=" + toYear,
dataType: "json",          
success: 
 function(data){                  
  $.each(data, function(index, item) {
   addBillsCheckboxes(item.bill_id,item.bill_period);
  });
}, //end the error function
error: 
 function(){
  alert("An error has occurred while fetching bills");
 } //end the error function
}); // end ajax call       
 } // end of function

============UPDATE==============

I changed POST style to:

url:"../components/billing/custompremstat.cfc",
            data: {
                method: "GetBillsArr",
                sponsor_id: sID,
                planenrolldate_id: plID,
                fM: fromMonth, 
                fY: fromYear, 
                tM: toMonth, 
                tY: toYear
            },

As a result I am getting error "The PLANENROLLDATE_ID parameter to the GetBillsArr function is required but was not passed in.
The error occurred on line -1. "

In the console planenrolldate_id looks like array. How to change parameter?

From console:

fM  9
fY  2014
method  GetBillsArr
planenrolldate_id[] 564
planenrolldate_id[] 561
sponsor_id  59
tM  9
tY  2014

Solution

  • Don't POST with a GET-style url. You aren't really posting like this....

    Send the parameters to the script with a POST as data

    $.ajax({
      type: "POST",
      url: "../components/billing/custompremstatus.cfc",
      data: { 
         method : "GetBillsArr",
         planenrolldate_id : plID,
        // ... etc
     }
    });
    

    and of course look for the posted version of the request in your CFM script.