开发者

POST serialized JSON object to a Coldfusion remote method instead of using FORM

开发者 https://www.devze.com 2022-12-27 15:24 出处:网络
I have javascript object which consists of complex array of structures with nested structures of other javascri开发者_StackOverflow社区pt objects created dynamicaly on page etc. long story. I can\'t u

I have javascript object which consists of complex array of structures with nested structures of other javascri开发者_StackOverflow社区pt 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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消