POST serialized JSON object to remote Coldfusion method instead of using FORM
I have a javascript object that is composed of a complex array of structures with nested structures of other javascript objects created dynamically on the page, etc. long story. I cannot use the form as my vars will be like 2_34_x_y_foo_bar_235423 due to the nature of the UI.
When I send this gated object with a GET.ajax request to the remote cfc method everything works fine until the JSON is longer than 4000+ and it will usually be longer than that.
When I use POST.ajax I get 302 status and redirect to cfcexplorer.
Is there a way that I could "attach" the object to the form and submit my data as submit, or in some way send the JSON object since it is now using an ajax call?
a source to share
When submitting in a remote CFC method, you must ensure that you still have your method = cfcMethodName as part of the request.
You can store this in the URL part (POST / mycfc.cfc? Method = myMethodName), or you can add it as a form field in the post.
Forwarding is a CF not getting a method to run and so I think you are trying to introspect a CFC.
a source to share
This is pretty much what I am doing in the current project:
form = $("<form method='POST' action='/foo'><input type='hidden' name='data'></form>")
form.find("input").val(JSON.stringify(my_data_object));
form.hide().appendTo($("body")).submit();
(Note that I have no experience with Coldfusion, this is a Python project.)
a source to share