Templates 我可以访问模板I'中Coldfusion页面上的变量集吗;如果不使用会话作用域,是否正在加载?
我有一个Coldfusion8页面,其中我预先声明了一些变量,如下所示:Templates 我可以访问模板I'中Coldfusion页面上的变量集吗;如果不使用会话作用域,是否正在加载?,templates,variables,coldfusion,global-variables,scope,Templates,Variables,Coldfusion,Global Variables,Scope,我有一个Coldfusion8页面,其中我预先声明了一些变量,如下所示: <cfif (structKeyExists(url,"extern"))> <cfset variables.someVar = "value"> <cfelse> <cfset variables.someVar = ""> </cfif> 因此,我的问题应该是: 如果内容在同一个页面上,并且我不想使用会话或应用程序作用域,那么Coldfus
<cfif (structKeyExists(url,"extern"))>
<cfset variables.someVar = "value">
<cfelse>
<cfset variables.someVar = "">
</cfif>
因此,我的问题应该是:
如果内容在同一个页面上,并且我不想使用会话或应用程序作用域,那么Coldfusion变量是否可以通过AJAX调用持久化?您可以使用请求作用域。这将允许您访问请求中的任何变量,包括模板 但我使用的方法是使用前缀为..的cfimport。。“用户界面”
不要误会,但你真的必须开始在问题中包含错误信息(或错误结果的描述)。因为根本不清楚“有麻烦”是什么意思:)@Leigh-ok。下一个问题;-)没有时间能像现在这样:顺便说一句,从技术上讲,你所描述的应该按原样工作。包含的模板可以访问调用页面的
变量
范围。如果没有,听起来像是我们不知道正在发生的事情:)你在哪里设置变量?如果您的第一个代码段位于Application.cfc内部,那么您正在访问cfc的变量范围,而不是页面的变量范围。改用请求作用域。等等,我现在看到你的代码了。。。您希望在一个完全不同的请求中获得一个变量。当您调用$.ajax时,这是一个全新的请求。。。当前页面或任何其他页面中的任何内容都不会输入其中。它只知道有人叫它。这几乎就像在一个新的浏览器窗口中自己打开它一样。如果tmp_searcher.cfm需要知道一些东西,您需要通过POST或url vars.ah传递它。那么,someVar?酷。我不知道!谢谢
<cfinclude template="templates/tmp_pagetop.cfm">
<cfoutput><head></cfoutput>
<cfinclude template="templates/tmp_pageheader.cfm">
...
<cfif (structKeyExists(url,"extern"))>
<!--- preload external user data --->
<cfstoredproc procedure="proc_select_extern" datasource="dtb">
<cfprocparam type="in" value="#Session.extern#" cfsqltype="cf_sql_varchar" maxlength="13">
<cfprocresult name="external_user">
</cfstoredproc>
<!--- set external variables --->
<cfif external_user.recordcount eq 1>
<cfoutput query="external_user">
<cfscript>
// CULPRIT string
variables.user_modules = external_user.modules;
</cfscript>
</cfoutput>
<cfelse>
<!--- remove unknown URL params --->
<cfset StructDelete(Session, "Extern")>
</cfif>
</cfif>
$(document).on('pagebeforeshow', '#search' , function(e, data) {
// load main search form
if ( $(this).attr('val') != true ) {
$(this).attr('val') == true;
// here I'm calling the default search form
ajaxUpdate( "../layouts/tmp_searcher.cfm", $('.searchFromWrapper'), "search", "default", "search" );
}
....
var ajaxUpdate =
function update( from, target, param, account, bindings ) {
$.mobile.loading( 'show' );
$.ajax({
async: true, type: 'GET', returnFormat: 'json',
data: { value: param, type: account },
url: from, timeout: 7500,
success: function(data) {
var makeUp = !$.support.touch ? data.replace("<select", "<select data-native-menu='false' ") : data;
target.addClass('.fade.out')
.html( makeUp )
...
});
<cfdump output="D:\ColdFusion8\logs\dump.txt" label="catch" var="#variables.user_module#">
Element USER_MODULE is undefined in VARIABLES
<cfimport taglib="templates" prefix="ui">
<ui:tmp_pagetop heyLookAVar="#myvar# >
<ui:page>
my page
</ui:page>