我不知道为什么我会得到这个。如果我浏览到
http://www.phillipsenn.com/Matrix/JSON/Upload/Upload.cfc?method=Save&Item=1
然后组件正常工作。但如果我这样做,它会要求输入 RDS 密码。
!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);
最后,这是我的组件:
<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>