I a problem that has been driving me nuts for awhile now. Here is the set up:
I have a draggable list that is being used for user navigation. I would like to save how the user orders the list to a database so it is the same the next time they load the page. I am using (or trying to) use an ajax call to save the order.
Here is my jQuery:
$(document).ready(function() {
$( "#sortable" ).sortable({
revert: true,
stop: function(event, ui) {
var aResult = $('#sortable').sortable('toArray');
postChanges( aResult );
}
});
});
function postChanges( result ) {
$.ajax({
type: "POST",
url: "model/customNav.cfm",
data: {order: result },
timeout: "5000"
});
}
On the cfm page “CustomNav” I have a simple cfdump to dump the form variable out to make sure the data is getting sent correctly:
(I tried to post an image but I am too new, I will try and “draw” the results from the cfdump)
|struct |
|Fieldnames| ORDER[] |
|ORDER[] | 3,2,1 |
The problem is, how do I access the order data? I figured because it was dumping the form structure, I would use dot notation to gain access to the order (i.e. form.order). That does not work. When I try and dump form.order I get an error saying the variable order is not found inside form.
I suspect it has to do with how I am sending the data to the coldfusion page, however I am not sure what I am doing wrong. So my question is, if I am sending the data correctly to the coldfusion page, how do I access it? If I am sending the data incorrectly, where did I go wrong?
Thanks much!
You could also try just accessing form[“order[]”]