I’m not sure why I’m getting this. If I browse to
http://www.phillipsenn.com/Matrix/JSON/Upload/Upload.cfc?method=Save&Item=1
Then the component works correctly.
But if I do this, then it asks for the RDS password.
!function($, window, undefined) {
var local = {};
local.data = {};
local.type= 'post',
local.dataType= 'json',
local.data.method = 'Save';
local.data = {
Item : 'Item One'
}
var myPromise = $.ajax('Upload.cfc',local);
myPromise.done(function(result) {
console.log('success!');
});
myPromise.fail(function(A,B,C) {
$('body').append(A.responseText);
console.log(B);
console.log(C);
});
}(jQuery, window);
Finally, here’s my component:
<cfcomponent>
<cffunction name="Save" access="remote" output="yes">
<cfargument name="Item">
<cfset var local = {}>
<cfquery datasource="#Application.Datasource#" username="#Application.Username#" password="#Application.Password#">
INSERT INTO lru.Clip(ClipDesc) VALUES('test')
</cfquery>
#arguments.Item#
</cffunction>
</cfcomponent>
Phil,
I’m guessing that somehow your ajax code is calling the CFC without the “method” url param. When it does this CF thinks you are going to try the “CFC Explorer” – a neat little tool that creates a Javadoc like description of your CFC. You can see it (even on local) if you simply browse to your CFC without any url params as in:
http://www.phillipsenn.com/Matrix/JSON/Upload/Upload.cfc
So something has to change with your Ajax call… I think that the issue is your last set statement…
is replacing the “data” sets above it….. with a single struct called “Item”. you are losing the key called “method” when you do it this way. Try: