Search code examples
jquerycoldfusioncoldfusion-8cfajaxproxy

How to submit one thousand checked check boxes via ajax?


I am using ColdFusion 8 and jQuery 1.7.2.

I use a ton of ajax in my sites. Normally, I would use CFAJAXPROXY, but this has a limitation: It puts all values into the URL, which is limited to about 1250 characters. My data would exceed that (1,000 values of 4 digits each).

I do not usually submit whole forms at once. I usually submit small pieces of info as required, such as when a box is checked or unchecked. This works very well using CFAJAXPROXY. Now I need to submit one thousand (or more) checkboxes at the time and this throws a wrench in my system.

How can I submit this FORM as FORM POST without refreshing the entire page, like normal form posts do?

// I WANT TO REFRESH THIS DIV ON FORM SUBMISSION
<div>
<fieldset>
<form method='post' action='?' id='jsSaveAllManufacturersForm'>
<input type='button' value='Select All ' id='jsSelectAll'>
<input type='button' value='Deselect All ' id='jsDeselectAll'> 
<input type='button' value='Save Changes' id='jsSaveChanges'>
<input type='checkbox' value='1'> 1
<input type='checkbox' value='2'> 2
<input type='checkbox' value='3'> 3
</form> 
</fieldset>
<div>

// SET VARS 
var $SaveAllManufacturersForm = $('#jsSaveAllManufacturersForm'),
$SelectAll = $('#jsSelectAll'),
$DeselectAll = $('#jsDeselectAll'),
$SaveChanges = $("#jsSaveChanges");

// MY FUNCTION WHEN FORM IS SUBMITTED
var saveChanges = function(e) {
e.preventDefault();
$SaveAllManufacturersForm.submit();
    jroDash.saveAllManufacturers($SaveAllManufacturersForm);
}

// ACTION THAT LAUNCHES THE FORM SUBMISSION
$SaveChanges.click(saveChanges);

Solution

  • CFAJAXPROXY can easily be set to use POST instead of GET.

    <cfajaxproxy cfc="CFCName" jsclassname="CFProxy"> 
    
    <script>
        myProxy = new CFProxy();
        myProxy.setHTTPMethod('POST');
        myProxy.doMyAjaxMethod();
    </script>`
    

    http://forta.com/blog/index.cfm/2007/10/15/Using-POST-For-ColdFusion-Ajax-Calls