On my site right now, I’m passing in data through a query string to a page. I’d like to change that so that the data is passed as a POST parameter.
My previous statement looked like this:
<cf_location url="mypage.cfm?id=123">
And I replaced it with:
<cfhttp method="post" url="mypage.cfm">
<cfhttpparam name="theID" type="URL" value="123">
</cfhttp>
But cfhttp isn’t posting anything. In Firebug, nothing shows up in the NET tab, and nothing happens when that code is supposed to run.
Am I doing this incorrectly? Am I using the right type in the cfhttpparam? I’m very new to ColdFusion, so this is difficult for me.
Assuming you want the server, and not the client, to see the result, you can use CFHTTP. As Edward pointed out, the client will never see the interaction, as it is only between the server and (in your example) itself (although you need a fully qualified URL, including host name or IP).
In your example, there are a few things wrong:
This, with a bit of tweaking (specifically the URL) should work:
Remember, the response is coming back to the server, so the end user will never see mypage.cfm. The response will be returned to the server in the CFHTTP variable (you can change that using the “result” attribute).
Unless you don’t have control of mypage.cfm, it might be easier to edit it to take URL variables, or to use structAppend() to copy the URL variables to the FORM scope.