0

.post を使用して CFC に送信するページがあります。データベースが更新されているため、関数が正常に機能することはわかっていますが、発生しているアラートは「else」ステートメントのアラートです。

私のリターンが正しいアラートを発していない理由が分かる人はいますか? リターンを適切にキャプチャしていませんか?

私の変数のいくつかは、テスト目的でハードコーディングされています...

jQuery:

$(document).ready(function() {
    var theID = $('#window_one h1').attr('name').split("-")[1];
    var gateway = ("001");
//Populate the form
    $('#theText').attr('value', $('#window_one h1').html());
    $('#texteditform').submit(function(e){
         //stop the form submission
      e.preventDefault()                               
        var newText = $('#theText').val();
        //CFC
        $.post("cfc/engine.cfc?method=updateText&returnformat=json", 
            {text:newText, field:theID, gateway_id:gateway},
            function(res) {
                //Handle the result
                if(res == "true") {
                    alert("worked fine");
                } else {
                    alert("Didn't Work");
                }
            });
    });                        
});

</script>

CFC

 <cffunction name="updateText" access="remote" output="no" returntype="boolean">


    <cfargument name="field" type="string" required="yes">
    <cfargument name="text" type="string" required="yes">
    <cfargument name="gateway_id" type="string" required="yes">
<cfquery datasource="#application.datasource#" username="#application.username#" password="#application.password#">
    UPDATE gateway
    SET #arguments.field# = <cfqueryparam value="#arguments.text#" cfsqltype="cf_sql_varchar">
    WHERE gateway_id = #arguments.gateway_id#
  </cfquery>
  <cfreturn true>
</cffunction>
4

1 に答える 1

4

CFが出力を生成する方法のために、余分な空白があります。cfc自体がoutput="false"に設定されていることを確認する必要があります...さらに少し揺れるかもしれませんが、それで始めることができます。

これはCFの最も厄介な機能の1つです

于 2010-07-13T19:27:32.940 に答える