Invoke ColdFusion function using AJAX

前端 未结 6 747
Happy的楠姐
Happy的楠姐 2020-12-01 16:58

I need to invoke a ColdFusion function(present in a .cfm file) when the user clicks on a link. And I would like to do it using jQuery. I have a jQuery snippet which looks li

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 17:05

    Using a ColdFusion variable in JavaScript is powerful! Be sure to use

     var #toScript(ColdFusionVAR, 'javascriptVar')# 
    

    You can now reference your variable as javaScriptVar using CFAJAXPROXY

    Be sure to include this in your template

     
    
    
    

    Using your class on the JavaScript side.

    You would us it like so.

    var JS_CFC_Obj;
    
    JS_CFC_Obj = new jsCFCclassName()
    

    You can now make calls to functions inside of that cfc.

    jsCFCclassName.functionName(javascript var);
    

提交回复
热议问题