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?

1
  • How are you doing the "POST" - are you simply sending the stringified JSON data, or are you doing something like jsondata=...? Most "standard" web apps would probably not like a POST with a single string rather than a "formfield=value" style posting, due to their parsing mechanisms (unless you've handrolled your own...) Commented Apr 19, 2010 at 15:39

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.)

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.