我正在使用 AJAX 和 Coldfusion 提交表单。在表单中,我有一个调用 js 函数 login() 的按钮。该函数是设置coldfusion组件实例,调用cfc组件中的loginUser()方法。
当我将名字和姓氏从 javascript 传递给 loginUser 函数时,一切正常。loginUser(firstname,lastname) 但是每当我尝试将实际的电子邮件地址传递给表单时,CF 都会抱怨。所以为了简单起见, loginUser("one","two","three") 会起作用,但 loginUser("one","two", "three@") 不起作用,CF 会显示消息:
调用 CFC /ATCdev/JanuszChudzynski/MobileWeb/ajax.cfc 时出错:未找到 [通过在 URL 参数中添加“cfdebug”来启用调试以查看更多信息]
所以我有两个问题。
1 我怎样才能让它工作?
2 如果我正在使用如何添加 CFDebug
<cfajaxproxy cfc="ajax" jsclassname="proxy" />
设置 cfc 代理。
提前致谢!
我在下面粘贴代码:
氟氯化碳
<cffunction name="loginUser" access = "remote" returntype="string">
<cfargument name="firstname" type="string" required="true" />
<cfargument name="lastname" type="string" required="true" />
<cfargument name="useremail" type="any" required="true" default=""/>
<cfargument name="license" type="string" required="false" />
<cfargument name="workshopid" type="string" required="false" />
<cfreturn "#firstname##lastname##useremail#">
</cffunction>
JS
function validatelogin(){
var check = $("#loginForm").valid();
console.log("check "+check);
if(check)
{
login();
}
}
function login(){
var instance = new proxy();
instance.setCallbackHandler(loginCallback);
var id = $("input[name='workshop']:checked").val();
var firstname = $("#firstname").val();
var lastname = $("#lastname").val();
var email = $("#email").val();
var licensenumber = $("#licensenumber").val();
console.log(id + " " + firstname + " " + lastname + " " + email + " " + licensenumber);
if(id&&firstname&&lastname&&email&&licensenumber){
//instance.loginUser(firstname,lastname,email,licensenumber,id);
console.log(" Email: "+email);
instance.loginUser(firstname,lastname,"jchudzynski@");
// instance.loginU();
}
else{
console.log("Javascript Error. Not all fields are valid.");
}
}
HTML
<form name="loginForm" id="loginForm" action="loginform.cfm">
<fieldset data-role="controlgroup">
<legend>Select your workshop from options below </legend>
<input type="radio" name="workshop" id="workshop1" class="custom" data-mini="true" value="workshop1" checked/>
<label for="workshop1">Workshop 1.</label>
<input type="radio" name="workshop" id="workshop2" class="custom" data-mini="true" value="workshop2"/>
<label for="workshop2">Workshop 2.</label>
</fieldset>
<div data-role="fieldcontain">
<label for="firstname" >First Name:</label>
<input type="text" name="firstname" id="firstname" value="" placeholder="First Name" data-mini="true" class="required" />
</div>
<div data-role="fieldcontain">
<label for="lastname" >Last Name:</label>
<input type="text" name="lastname" id="lastname" value="" placeholder="Last Name" data-mini="true" class="required" />
</div>
<div data-role="fieldcontain">
<label for="email" >Email:</label>
<input type="text" name="email" id="email" value="" placeholder="email" data-mini="true" class="required email" />
</div>
<div data-role="fieldcontain">
<label for="licensenumber" >License Number:</label>
<input type="text" name="licensenumber" id="licensenumber" value="" placeholder="License Number" data-mini="true" class="required" />
</div>
<input type="button" value="Login" onclick="validatelogin()"/>
</form>