私はColdFusionMX7を使用して単純なフォームに取り組んでいます。cfselectで選択されたものに基づいて入力したいテキスト入力のペアがあります。私のCFCへのAjax呼び出しは、404エラーを返します。ブラウザからCFCにアクセスしても、そのようなエラーは発生しません。これは、CFC用のカスタムJavaプロキシを作成するBenNadelの例を使用して作成しました。cfcは、このスクリプトが存在するcfmページと同じフォルダーにあります。関連するコードは次のとおりです。
function RemoteCFC(){
this.name = " ";
return( this );
}
// This handles the remote calls to the CFCs.
RemoteCFC.prototype.MakeRemoteCall = function(strMethod, objData, fnSuccess, fnError){
// Create a data struct and extend it with the method
// name and the data to be passed.
var objRemoteData = {};
// Extend the remote data set.
$.extend(objRemoteData, objData, {method: strMethod, returnFormat: "json"});
// Make the AJAX call to the remote method.
$.ajax({type: "get", url: (this.Name + ".cfc"), data: objRemoteData, dataType: "json",
success: fnSuccess, error: fnError});
// Return this for method chaining.
return( this );
}
// Create a new core remote object. We will need this
// to create the prototype chain such that the other
// proxy classes can extend this.
objRemoteCFC = new RemoteCFC();
// Create a Javascript proxy for this given CFC.
function RecallService(){
this.Name = "RecallCountFunctions";
}
// Extend the core CFC Proxy functionality.
RecallService.prototype = objRemoteCFC;
RecallService.prototype.getInspected = function( objData, fnSuccess, fnError ){
this.MakeRemoteCall( "getInspected", objData, fnSuccess, fnError );
}
//Define another remote method wrapper.
RecallService.prototype.getHeld = function( objData, fnSuccess, fnError ){
this.MakeRemoteCall( "getHeld", objData, fnSuccess, fnError );
}
$(
function(){
var myRecallService = new RecallService();
$( "select[ name = 'CountChosen' ]" ).change( function(){
var selectedCount = $( "select[ name = 'CountChosen' ]" );
var inspected = $("input[name='numInspected']");
var held = $("input[name='numHeld']");
if (selectedCount.val() != "0"){
EnableForm();
myRecallService.getInspected({store: "#cgi.AUTH_USER#", id: selectedCount}, function
( objResponse ){SetValue("inspected", objResoponse );}, function( objResponse ){
alert( objResponse.responseText );});
myRecallService.getHeld({store: "#cgi.AUTH_USER#", id: selectedCount}, function
( objResponse ){SetValue("held", objResponse);}, function( objResponse ){
alert( objResponse.responseText);});
}
});
}
長い投稿について申し訳ありませんが、私は役立つかもしれないすべてのものを除外したくありませんでした。また、Application.cfcを使用していないか、問題が発生する可能性があると聞いたonRequestメソッドを使用していません。
私のcfcを見る必要がある場合は、私も投稿できることを知らせてください。
修正は次のとおりです。
Change:
id: selectedCount
To:
id: selectedCount.val()