我是 jquery 的新手,我正在尝试使用对话框调用和更新我的数据库的函数。我修改了现有模板以生成下面的代码,但无法让 jquery 函数调用函数 savefee。我的 javascript 控制台中没有错误。任何帮助表示赞赏。
`
<cfset getfees = new artservice().getfees()>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$(".artdiv").click(function() {
var initialDiv = this;
//based on which we click, get the current values
var feeid = $(this).data("fee_id");
var feetitle = $("h2", this).text();
// set form values
$("#fee_id").val(feeid);
$("#fee_title").val(feetitle);
$("#editForm").dialog({
buttons: {
"Save": function() {
var thisDialog = $(this);
$.post("artservice.cfc", {
method: 'savefee',
fee_id: $("#fee_id").val(),
fee_title: $("#fee_title").val()
},
function() {
//update the initial div
$("h2", initialDiv).text($("#fee_title").val());
$(thisDialog).dialog("close");
});
}
}
});
});
});
</script>
<style>
.artdiv {
padding: 5px;
margin: 5px;
background-color: #80ff80;
}
#editForm {
display:none;
}
</style>
</head>
<body>
<cfoutput query="getfees">
<div class="artdiv" data-fee_id="#fee_id#">
<h2>#fee_title#</h2>
</div>
</cfoutput>
<div id="editForm" title="Edit Art">
<input type="hidden" id="fee_id">
<p>
<b>Name:</b><br/>
<input type="text" id="fee_title">
</p>
</div>
</body>
</html>
`
cfc 如下
`
<cffunction name="getfees" access="public">
<cfquery datasource="dsn" name="getfees" maxrows="10">select fee_id, fee_title from table</cfquery>
<cfreturn getfees>
</cffunction>
<cffunction name="savefee" access="public">
<cfargument name="fee_id" required="yes">
<cfargument name="fee_title" required="yes">
<cfquery datasource="dsn">update table set fee_title = '#arguments.fee_title#' where fee_id = #fee_id#</cfquery>
</cffunction>
`
application.cfc 中的此函数出现错误“传递给 onCFCRequest 函数的 ARGS 参数不是字符串类型”
public void function onCFCRequest(required string cfcname, required string method, required string args) {
return;
}