Call to CFC via Ajax-POST does not work
- by Philipp
We have the following problem:
A CFC-method that is called from AJAX suddenly redirects the request to cfcexplorer instead of executing the request. The strange thing is, that the problem only occurs when we make the ajax call via "POST" method, like this:
// This will return the HTTP Status header:
// Location: http://url.to:80/CFIDE/componentutils/cfcexplorer.cfc?method=getcfcinhtml&name=web.ajax&path=/web/ajax.cfc
$.post(
"http://url.to/ajax.cfc",
{method: "test"},
function(res) { alert("ajax.cfc POST return:" + res); }
);
Making the same request as "GET" request works perfectly:
// This will call the method "test" of web/ajax.cfc
$.get(
"http://url.to/ajax.cfc",
{method: "test"},
function(res) { alert("ajax.cfc GET return:" + res); }
);
This is the ajax.cfc file (dummy file):
<cfcomponent>
<cffunction name="test" access="remote" returntype="Any" returnformat="JSON">
<cfset j = {}>
<cfset j.data = "this is the data">
<cfreturn serializeJson(j)>
</cffunction>
</cfcomponent>
What really puzzles us is that the request did work in the past (we have a lot of code all making ajax calls via POST and CF-code that expects FORM-data to be present, so we cannot simply change the method to GET)
Maybe there was some setting that has changed or similar...