views:

192

answers:

2

I have javascript object which consists of complex array of structures with nested structures of other javascript objects created dynamicaly on page etc. long story. I can't use form since my vars would be like 2_34_x_y_foo_bar_235423 due to the nature of UI.

When I send that stringified object using GET .ajax request to a remote cfc method everything runs ok until JSON becomes 4000+ chars long, and usually it will be longer then that.

When I use POST .ajax, I get 302 status and redirection to cfcexplorer.

Is there some way I could "attach" object to a form and send my data as form submit, or some way to send JSON object as it is now using ajax call?

+2  A: 

This is pretty much what I'm doing in a 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 whatsoever; this is a Python project.)

balpha
I was thinking exactly the same, somehow didn't work at once so I gave up thinking it can't be done like that. Good tip.
zarko.susnjar
+3  A: 

When posting to a remote CFC method, you have to make sure you still have your "method=cfcMethodName" as part of the request.

You can keep that in the URL part (POST /mycfc.cfc?method=myMethodName), or you can add it as a form field in the post.

The redirect is CF not getting a method to run, and therefore thinking you're trying to introspect the CFC.

Edward M Smith