AJAX和放大器; ColdFusion的:执行更新数据库,并反映了更改,恕不重装 [英] AJAX & Coldfusion: Performing an update to database and reflecting changes without reload

查看:223
本文介绍了AJAX和放大器; ColdFusion的:执行更新数据库,并反映了更改,恕不重装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,可视化,我在这里需要的解决方案。我在网站上选择菜单,我的工作,客户希望能够选择所谓的创建新起源的选项,这便拥有一个JS窗口弹出一个空白领域,为用户键入新的原点。

I'm having problems visualizing the solution that I need here. I have a select menu on the site that I'm working on and the client would like to be able to select an option called "Create New Origin", which would then have a JS window pop up with a blank field for the user to type in that new origin.

在提交此表的数据库将被更新,选择菜单现在将拥有该项目没有在页面的整个刷新。

Upon submitting this form the database would be updated and the select menu would now feature this item without an entire refresh of the page.

东西在数据库端是所有设置和准备去,为的​​是99%的Coldfusion的。

The database side of things is all set up and ready to go, as is 99% of the Coldfusion.

下面是有问题的表单域的一个片段:

Here's a snippet of the form field in question:

<p class="_30NP" align="right">
    <label>Origin&nbsp;</label>
</p>
<p class="_20NP">
    <cfselect 
     name="Origin" 
     id="Origin" 
     query="Origin" 
     display="description" 
     value="code"  
     required="yes">
        <option value="new">New Origin</option>
    </cfselect>
</p>

这里的CFQUERY:

Here's the CFQUERY:

<CFQUERY DBTYPE="Query" NAME="Origin">
    SELECT Code, [Description]
    FROM ZCODES WHERE CODE = 0
    UNION ALL 
    SELECT Code, [Description]
    FROM ZCODES
    WHERE FieldName = 'Origin'
    ORDER BY 1
</CFQUERY>

这是一个带有可能是一个非常简单的答案很简单的问题,我只是有一点接触到AJAX。

This is a very simple question with probably a very simple answer, I just have little exposure to AJAX.

我如何提交一个表单(弹出窗口),并刷新选择列表中没有完全刷新页面?

How do I submit a form (pop up window) and refresh the select list without completely refreshing the page?

推荐答案

我会用一个JavaScript如 jQuery的图书馆您处理Ajax。

I would use a javascript library like jQuery to handle your ajax.

一旦点击此按钮使用 $。获得(),的 $。员额()或的 $。阿贾克斯()与服务器进行通信。每个将提供一个响应。响应类型是由你。你可以返回JSON和解析出来,或者你可以直接返回HTML。我可以简单地返回HTML是快速和容易。

Once the button is clicked use $.get(), $.post(), or $.ajax() to communicate with the server. Each will provide a response. The response type is up to you. You could return JSON and parse it out, or you could return straight HTML. I might simply return html to be quick and easy.

<cfoutput query = "...">
    <option value = "...">...</option>
</cfoutput>

一旦有了结果,使用 $ html的()更新选择的选项。

这篇关于AJAX和放大器; ColdFusion的:执行更新数据库,并反映了更改,恕不重装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆