我一直无法让 Railo 在测试页面上使用新的 CFC,并在错误控制台中不断收到"Railo 未定义"
错误控制台突出显示此部分:
var _Railo_proxytest = Railo.ajaxProxy.init('/proxytest.cfc','proxytest');
代码 CFC:
<cfcomponent>
<cffunction name="test1" access="remote" returntype="string" output="no">
<cfargument name="name" type="string" required="yes" default="Nameless">
<cfreturn "#areguments.name#">
</cffunction>
</cfcomponent>
代码 CFM:
<cfajaxproxy cfc="proxytest" jsclassname ="proxytest">
<script>
var myProxy = new proxytest();
function runProxy() {
var name = document.getElementById("name").value;
var results = myProxy.sayHello(name);
}
</script>
<form>
<input type="text" id ="name">
<input type="button" onclick="runProxy()" value="Run">
</form>
尝试如下:
var proxytest = Railo.ajaxProxy.init('/proxytest.cfc');
您的示例代码中有一个拼写错误:<cfreturn "#areguments.name#">
应该<cfreturn "#arguments.name#">
此外,您发布的代码不会加起来。您正在从 Javascript 调用函数sayHello()
,但 CFC 没有此函数。发布实际代码而不是重写通常是明智的。
如果直接从浏览器调用/proxytest.cfc?method=test1&name=MyName
会发生什么情况?