我一直在尝试找到一种方法来做一些看起来很简单但似乎无法找到解决方案的方法。我有一篇用一些 HTML 制作的帖子,并希望动态更改其中的部分内容。我将 Coldfusion 9 用于服务器端、AJAX 和 jQuery UI 1.10.1 和 jQuery 1.9.1。
我想做的是在 AJAX 中发布并替换 cfc 中的数据服务器端。这是我在客户端的代码。
var ipost = '<li> <h2><a href="PersonsID" target="_blank">Persons Name</a></h2> </li>';
var message_a = $('#message_a').attr('value');
$.ajax({
type: "POST",
url: "cfc/cfc_Forum.cfc?method=func_AddNew&returnformat=json",
data: { message:"message_a=" + wall_post },
success: function () {
$('ul#posts').prepend(ipost);
}
});
我想用“Session.Variable1”替换“PersonsID”,用“Session.Variable2”替换“Persons Name”。cfc 将是 CF 的标准协议。这是组件的外观。
<cfcomponent>
<cffunction name="func_AddNew" access="remote" returntype="struct">
<cfargument name="message" type="string" required="true" />
<--- ********** replace "Persons ID" and "Persons Name" ************** --->
<!--- ********* INSERT INTO DATA BASE ************ --->
<cfreturn return />
</cffunction>
</cfcomponent>
任何建议都会很棒!