Call to CFC via Ajax-POST does not work
Posted
by
Philipp
on Stack Overflow
See other posts from Stack Overflow
or by Philipp
Published on 2013-10-22T07:54:22Z
Indexed on
2013/10/22
9:55 UTC
Read the original article
Hit count: 416
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...
© Stack Overflow or respective owner