Coldfusion 执行存储过程而不刷新页面?

发布于 2024-12-21 04:41:57 字数 586 浏览 3 评论 0原文

我有一个带有“选择”参数的存储过程

<cfstoredproc procedure="MyProcedure" datasource="MyDataSource">
  <cfprocparam type="in" cfsqltype="cf_sql_integer" value="#selection#" null="no">
</cfstoredproc>

我有一个选择框,用户可以在其中选择该框,我想使用 jquery 来“调用”存储过程:

$(document).ready(function(){
        $('#selectbox').change(function() {
            // update my #selection# variable
                        // run the stored procedure again (the one above)
        });
    });

有没有办法做到这一点?我知道它混合了客户端和服务器端代码,但我无法刷新页面,因为页面上有多种表单......

I have a stored procedure with a "selection" parameter

<cfstoredproc procedure="MyProcedure" datasource="MyDataSource">
  <cfprocparam type="in" cfsqltype="cf_sql_integer" value="#selection#" null="no">
</cfstoredproc>

I have a select box where the user can select the box, and I would like to use jquery to "call" the stored procedure:

$(document).ready(function(){
        $('#selectbox').change(function() {
            // update my #selection# variable
                        // run the stored procedure again (the one above)
        });
    });

Is there a way to do this? I know it's mixing client and server side code but I can't refresh the page because there are multiple forms on the page...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寄居人 2024-12-28 04:41:57
$(document).ready(function(){
        $('#selectbox').change(function() {
            $.get('pathToYourStoredProcCFM.cfm?selectVal=' + $(this).val(), function (res) {

               // if you need to handle the response to the stored proc 
               // on the client side (which was output in your CFM code), do so here
               // (the response from CF is stored in the "res" variable)

            });

        });
    });
$(document).ready(function(){
        $('#selectbox').change(function() {
            $.get('pathToYourStoredProcCFM.cfm?selectVal=' + $(this).val(), function (res) {

               // if you need to handle the response to the stored proc 
               // on the client side (which was output in your CFM code), do so here
               // (the response from CF is stored in the "res" variable)

            });

        });
    });
撩动你心 2024-12-28 04:41:57

您需要创建一个包含存储过程的 .cfm 页面,并使用 AJAX 调用来执行存储过程。

存储过程.cfm

<cfparam name="URL.selection" />

<cfstoredproc procedure="MyProcedure" datasource="MyDataSource">
  <cfprocparam type="in" cfsqltype="cf_sql_integer" value="#URL.selection#" null="no" />
</cfstoredproc>

$(document).ready(function(){
        $('#selectbox').change(function() {
            // update my #selection# variable
            $.get("storedProc.cfm", { selection: $(this).val() } );        
      });
    });

You'll need create a .cfm page with stored procedure in it and use an AJAX call to execute the stored proc.

storedProc.cfm

<cfparam name="URL.selection" />

<cfstoredproc procedure="MyProcedure" datasource="MyDataSource">
  <cfprocparam type="in" cfsqltype="cf_sql_integer" value="#URL.selection#" null="no" />
</cfstoredproc>

$(document).ready(function(){
        $('#selectbox').change(function() {
            // update my #selection# variable
            $.get("storedProc.cfm", { selection: $(this).val() } );        
      });
    });
爱你是孤单的心事 2024-12-28 04:41:57

您需要将 Stored Proc 调用放入单独的 CFM 文件中,以供 jquery 调用。您无法返回页面上调用的那个。

You will need to put your Stored Proc call into a seperate CFM file for your jquery to call. You can't reference back to the one called on your page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文