Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用cfajaxproxy对coldfusion组件的Ajax调用_Javascript_Ajax_Coldfusion_Cfajaxproxy - Fatal编程技术网

Javascript 使用cfajaxproxy对coldfusion组件的Ajax调用

Javascript 使用cfajaxproxy对coldfusion组件的Ajax调用,javascript,ajax,coldfusion,cfajaxproxy,Javascript,Ajax,Coldfusion,Cfajaxproxy,我被以下代码困住了,希望有人能帮助我或给我一些建议: 基本上,我所做的是使用ajax调用cf函数:当用户在字段artid中写入id时 与该id相关的信息将显示在其他cfinput中。上面的代码运行良好 <cfajaxproxy bind="cfc:portal_dgmu.pruebas.addPerson.test.getData({artid@keyup})" onsuccess="showData"> <script> function showData(d) {

我被以下代码困住了,希望有人能帮助我或给我一些建议: 基本上,我所做的是使用ajax调用cf函数:当用户在字段artid中写入id时 与该id相关的信息将显示在其他cfinput中。上面的代码运行良好

<cfajaxproxy bind="cfc:portal_dgmu.pruebas.addPerson.test.getData({artid@keyup})" onsuccess="showData">

<script>

function showData(d) {
var data = {}
for(var i=0; i < d.COLUMNS.length; i++) {
    data[d.COLUMNS[i]] = d.DATA[0][i]
}
document.getElementById('artname').value = data["ARTNAME"]
document.getElementById('description').value = data["DESCRIPTION"]
document.getElementById('price').value = data["PRIZE"]

}
</script>
<html>
<cfform>
id: <cfinput type="text" name="artid" id="artid"><br/>
nombre: <cfinput type="text" name="artname" id="artname" readonly="true"><br/>
descripcion: <cftextarea name="description" id="description" readonly="true"></cftextarea><br/>
precio: <cfinput type="text" name="price" id="price" readonly="true"><br/>
</cfform>
</html>
我还有以下代码:

<script>
function addFields(){
        var number = document.getElementById("member").value;
        var container = document.getElementById("container");
        while (container.hasChildNodes()) {
            container.removeChild(container.lastChild);
        }
        for (i=0;i<number;i++){
            container.appendChild(document.createTextNode(i+1));
            var input = document.createElement("input");
            input.type = "text";
            input.name = "member" + i;

    var boton = document.createElement("input");
            boton.name = "boton" + i;       

            container.appendChild(input);
    container.appendChild(boton);
            container.appendChild(document.createElement("br"));
        }
    }
</script>

<html>
Enter a number of persons: (max. 10)<input type="text" id="member" size="3" name="member" value="">
<a href="#" id="filldetails" onclick="addFields()">Agregar</a>
<div id="container"/>
</html>
上面的代码只是根据用户输入的数字添加文本字段,它也可以正常工作

<cfajaxproxy bind="cfc:portal_dgmu.pruebas.addPerson.test.getData({artid@keyup})" onsuccess="showData">

<script>

function showData(d) {
var data = {}
for(var i=0; i < d.COLUMNS.length; i++) {
    data[d.COLUMNS[i]] = d.DATA[0][i]
}
document.getElementById('artname').value = data["ARTNAME"]
document.getElementById('description').value = data["DESCRIPTION"]
document.getElementById('price').value = data["PRIZE"]

}
</script>
<html>
<cfform>
id: <cfinput type="text" name="artid" id="artid"><br/>
nombre: <cfinput type="text" name="artname" id="artname" readonly="true"><br/>
descripcion: <cftextarea name="description" id="description" readonly="true"></cftextarea><br/>
precio: <cfinput type="text" name="price" id="price" readonly="true"><br/>
</cfform>
</html>
我的问题是,我只是不知道如何将两者集成,我的意思是,我需要做的是取决于部署的用户类型文本字段的数量,第一个必须键入一个id,该id将带来与该id相关的数据


非常感谢你

下面是一个使用jquery的示例,它涵盖了您想要做的所有事情

我将ajax请求更改为在输入字段更改时触发而不是keyup,但是如果需要,您可以轻松地进行更改

如果使用cf<9,cfc可能需要更改,我只在firefox中测试过它,但它应该可以在其他浏览器中使用

index.cfm 试验装置
下面是一个使用jquery的示例,它涵盖了您想要做的所有事情

我将ajax请求更改为在输入字段更改时触发而不是keyup,但是如果需要,您可以轻松地进行更改

如果使用cf<9,cfc可能需要更改,我只在firefox中测试过它,但它应该可以在其他浏览器中使用

index.cfm 试验装置

帮自己一个忙..停止在ColdFUsion中使用and和任何其他客户端幻灯片功能。撕下所有thsi内容,并学习如何使用jQuery或其他JavaScript库在JavaScript中实现它。ColdFusion客户端的功能非常强大,您可能会遇到问题。特别是如果您现在刚刚开始使用这些东西,而不是做遗留的维护工作,请停止使用HTML和一个像样的JSUI库。ColdFusion UI除了概念验证之外,不适合任何其他用途,Adobe也不适合向IT经理销售CF许可证。谢谢你的建议,我从来没有使用过cfajaxproxy,我这么做是因为我觉得很简单,你能告诉我一些与我需要的相关的教程或示例吗,我非常感谢,我没时间解决这个问题。考虑到你在这个问题上寻求帮助,我会反驳你关于cfajaxproxy“简单”的断言。这里是开始学习jQuery及其.ajax方法的好地方@user2683052-如果我正确理解了这个目标,它涉及动态绑定到动态添加的表单字段。在这种情况下,您可能无法使用cfjaxproxy。请帮自己一个忙。停止在ColdFUsion中使用and和任何其他客户端幻灯片功能。撕下所有thsi内容,并学习如何使用jQuery或其他JavaScript库在JavaScript中实现它。ColdFusion客户端的功能非常强大,您可能会遇到问题。特别是如果您现在刚刚开始使用这些东西,而不是做遗留的维护工作,请停止使用HTML和一个像样的JSUI库。ColdFusion UI除了概念验证之外,不适合任何其他用途,Adobe也不适合向IT经理销售CF许可证。谢谢你的建议,我从来没有使用过cfajaxproxy,我这么做是因为我觉得很简单,你能告诉我一些与我需要的相关的教程或示例吗,我非常感谢,我没时间解决这个问题。考虑到你在这个问题上寻求帮助,我会反驳你关于cfajaxproxy“简单”的断言。这里是开始学习jQuery及其.ajax方法的好地方@user2683052-如果我正确理解了这个目标,它涉及动态绑定到动态添加的表单字段。在这种情况下,您可能无法使用cfjaxproxy.OMG!你太酷了!非常感谢你!!!你不知道我花了多少时间让这段代码正常工作。真的非常感谢你!这正是我需要的!!对不起打扰了,你能再帮我一件事吗?我需要cfquery,我知道怎么做,但我不知道如何让文本字段接收cfquery中的信息。谢谢我修改了.cfc,结果是:myQry=newquery;qryRes=myQry.executesql=select*from-art,其中artid='id'。getResult;ret[testInput]=qryRes.artname;ret[testArea]=qryRes.description;返回ret;但它不起作用。如果没有看到错误消息,我无法确定,但可能是因为缺少数据源ie local.myQry=new Querydatasource:SOME_datasource;local.qryRes=myQry.executesql=SQL.getResult;天啊!你太酷了!非常感谢你!!!你不知道我花了多少时间让这段代码正常工作。真的非常感谢你!这正是我需要的!!对不起打扰了,你能帮我一下吗
还有一件事吗?我需要cfquery,我知道怎么做,但我不知道如何让文本字段接收cfquery中的信息。谢谢我修改了.cfc,结果是:myQry=newquery;qryRes=myQry.executesql=select*from-art,其中artid='id'。getResult;ret[testInput]=qryRes.artname;ret[testArea]=qryRes.description;返回ret;但它不起作用。如果没有看到错误消息,我无法确定,但可能是因为缺少数据源ie local.myQry=new Querydatasource:SOME_datasource;local.qryRes=myQry.executesql=SQL.getResult;
<cfcomponent output="false">

    <cffunction name="getData" access="remote" output="false" returnformat="json">
        <cfargument name="id" type="string" required="true">
        <cfscript>
            local.ret = {};

            ret["testInput"] = rand();
            ret["testArea"] = "blah blah";
            return ret;
        </cfscript>
    </cffunction>

</cfcomponent>