TechBlog
leaflet
#js1k entry finally complete - AsciiBrot1K:http://urlm.in/flii - from T-SQL to JavaScript and then down to just 1KB of hand-compressed code

POSTing cfajaxproxy

Posted on 1 April, 2008 by maximinus in ,
On a similar tack to the URL length limit mentioned in my post about the moonwalking kiwi, today I discovered a minor issue with cfajaxproxy, along with the (very simple) solution.

By default, cfajaxproxy will use HTTP GET requests to interface with the server, which is all fine and dandy if you're just passing in an ID or two to the function, and expecting data back from the server.  However, if you're using the proxy to send data back to the server, you'll probably want to set the proxy to use POST rather than GET - otherwise you run into length limits related not only to the browser (and its XmlHttpRequest object), but of the webserver.  IIS in particular seems to have a lovely habit of returning cryptic 500 errors complaining about bad verbs.

As I said, once you've found out how to do it, it's very simple to make a proxy use POST.  Once you've created the proxy class using the <cfajaxproxy> tag, you instantiate it as per usual, and then use its setHTTPMethod function:
<cfajaxproxy cfc="yourapp.cfcs.bar" jsclassname="Bar">
<script type="text/javascript">
var foo=new Bar();
foo.setHTTPMethod('POST');
</script>
You can then proceed to use the object ('foo' in the example above) as before, without having to worry about exceeding the URL length limit(s).
No comments have been posted on this entry.
Post a comment:
Sorry, comments have been disabled.