我希望能够进行ajax调用并使用返回的结果使用vue.js生成下拉菜单的选项。我可以做这个:
<select v-model="selected">
<option v-for="option in options" v-bind:value="option.value">
{{ option.text }}
</option>
</select>
<span>Selected: {{ selected }}</span>
Run Code Online (Sandbox Code Playgroud)
.js文件
new Vue({
el: '...',
data: {
selected: 'A',
options: [
{ text: 'One', value: 'A' },
{ text: 'Two', value: 'B' },
{ text: 'Three', value: 'C' }
]
}
})
Run Code Online (Sandbox Code Playgroud)
但是我不想对我的选项进行硬编码,而是来自ajax调用。
Ajax调用看起来像这样:
function pullEmployees(){
var eventOwnerId = $('#eventOwner').val();
var eventOwnerName = $('#eventOwner :selected').text();
$.ajax({
url: "employees.cfm",
data: {
eventOwnerId: eventOwnerId,
eventOwnerName: eventOwnerName,
method : "updateOwners"
},
success: function(results) { …Run Code Online (Sandbox Code Playgroud) 我在CFC文件中有一个函数,它接受一个JSON字符串作为参数.然后,该函数使用反序列化的数据来执行UPDATE查询.在JSON字符串中,其中一个属性将该字符#作为名称的一部分.此字符使代码在ColdFusion中中断,因为它被解释为变量.有没有办法让ColdFusion"逃脱"那个角色,并认为它只是一个字符串?请记住,它是JSON字符串的一部分.
以下是我的功能.dnisObject由于#JSON字符串中的字符,它不允许我访问.如果我#从JSON字符串中删除它,它工作正常.这些值必须存储在数据库中#,因此我不能完全删除它们.
<cffunction name="updateDnisHproduct" access="remote">
<cfargument name = "lid" type = "numeric" required = "yes">
<cfargument name = "updatedObj" type = "string" required="yes">
<cfset dnisObject = DESERIALIZEJSON(arguments.updatedObj)/>
<cfset test =[{"phone":"1001106672","lineType":"Outbound","label1":"Voicemail for line #54940","label4":"test","hcat":"18","freshStart":"0","phoneCode":"","hproduct":"3","checked":false},{"phone":"1001106672","lineType":"Outbound","label1":"Voicemail Line Box #58940","label4":"12","hcat":"54","freshStart":"0","phoneCode":"","hproduct":"12","checked":false}'>
<cfset dnisObject = DESERIALIZEJSON(test)/>
</cffunction>
Run Code Online (Sandbox Code Playgroud) 我有这个代码:执行此代码时页面出错.我试图弄清楚它是如何看待从DeserializeJSON()方法反序列化的对象,我写了这个简单的场景,但它不起作用.有谁看到这里的问题是什么?
<cfset test = '[{"phone":"1001106672","label4":"12","hcats":"18","freshStart":"0","phoneCode":"","hproduct":"12","checked":false},{"phone":"1001106672","label4":"test","hcats":"54","freshStart":"0","phoneCode":"456","hproduct":"15","checked":false}]'>
<cfset test2 = DeserializeJSON(test)/>
<cfoutput>#test2#</cfoutput>
Run Code Online (Sandbox Code Playgroud) 我有一个字符串,表示一个或多个数字除以",",例如
"3", "5, 6, 9", "1, 4", "11, 4"
Run Code Online (Sandbox Code Playgroud)
我试着用:
`myString.indexOf("1") !=-1
Run Code Online (Sandbox Code Playgroud)
但对于包含1和11的字符串的无效数据,它返回true.我不想为字符串返回true:
"11, 4".indexof("1") !=-1
Run Code Online (Sandbox Code Playgroud)
我知道返回true是有道理的,但我的问题是如何在这种情况下编写函数不返回true,并且只有当数字1在字符串("1,8")上时才返回true.
我有这样的情况:
SELECT
fName,
lName
FROM employee as e
join payroll as p ON p.frn_employeeid = e.employeeId
Run Code Online (Sandbox Code Playgroud)
对于employeeId = 2(WHERE e.employeeId = 2)我还想在select子句payCheck上添加另一列
SELECT
fName,
lName,
payCheck (this column should show on the report ONLY if employeeId = 2)
FROM employee as e
join payroll as p ON p.frn_employeeid = e.employeeId
Run Code Online (Sandbox Code Playgroud)
我感谢任何有助于实现这一目标的帮助。
注意:我知道我可以做的一件事是使用两个查询,然后检查是否 employeeId =2 运行查询 1 否则运行查询 2 。我正在寻找是否可以只使用一个“SMART”查询