在哪里可以找到非常简单的 jQuery/AJAX Coldfusion 教程?

发布于 2025-01-03 04:54:07 字数 707 浏览 2 评论 0原文

编辑:在学习了一些教程后,我陷入了困境 此处

我是 jquery 新手,但对 Coldfusion 有一些经验。我一直渴望有一个简单的教程来展示 jQuery/AJAX 如何从 ColdFusion9 CFC 中提取查询并将其显示在 HTML 调用页面上。我尝试遵循此 ben_tutorial 但它太复杂了 我。还有另一个 教程,但我不想安装插件。我应该去哪里寻找?我正在谷歌搜索“jquery ajax Coldfusion”

Edit: After following a few tutorials I am stuck here

I am new to jquery but have some experience with Coldfusion. I have been desperate for an easy tutorial that shows how jQuery/AJAX pulls a query from a ColdFusion9 CFC and displays it on the HTML calling page. I tried following this ben_tutorial but it is too complex for me. There is also a another tutorial, but I do not want to install a plugin. Where should I be looking? I am googling "jquery ajax coldfusion"

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

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

发布评论

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

评论(3

小糖芽 2025-01-10 04:54:07

您没有详细说明要在客户端更新什么。表单很常见,因此如果您有客户端 html 表单,例如:

<input type="text" name="title">
<input type="text" name="date">
<input type="text" name="author">

您将使用 Coldfusion 生成并发送 JSON 字符串。 JSON 字符串可能类似于:

{"title" : "mytitle", "date" : "mydate", "author" : "myauthor"}

要更新客户端上的数据,您将执行(coldfusion-page.cfm 是服务器端 ajax 响应程序的名称):

jsonOBJ = {};
$.ajax({
  type: "GET",
  url: "coldfusion-page.cfm",
  cache: false,
  success: function(data){
     jsonOBJ = jQuery.parseJSON(data);
     for (var key in jsonOBJ) {
       $("input[name=" + key + "]").val(jsonOBJ[key]);
     }
  },
});

OR,如果您只想更新 div 或 textarea,例如:

<div id="uniquedivname"></div>

您只需发送 html/text 并将 ajax 调用中的 success 函数替换为:

  success: function(data){
     $("#uniquedivname").html(data);
  },

You didn't elaborate on what you want to update on the client side. Forms are common, so if you have client side html form like:

<input type="text" name="title">
<input type="text" name="date">
<input type="text" name="author">

You would generate and send a JSON string with coldfusion. The JSON string could look something like:

{"title" : "mytitle", "date" : "mydate", "author" : "myauthor"}

To update the data on the client side you would execute (coldfusion-page.cfm is the name of your server side ajax responder):

jsonOBJ = {};
$.ajax({
  type: "GET",
  url: "coldfusion-page.cfm",
  cache: false,
  success: function(data){
     jsonOBJ = jQuery.parseJSON(data);
     for (var key in jsonOBJ) {
       $("input[name=" + key + "]").val(jsonOBJ[key]);
     }
  },
});

OR, If you just want to update a div or textarea like:

<div id="uniquedivname"></div>

you just send the html/text and replace the success function in the ajax call with:

  success: function(data){
     $("#uniquedivname").html(data);
  },
一个人的旅程 2025-01-10 04:54:07

我假设您对 HTML 有一定的了解。要完成您所要求的任务,请使用以下代码片段:

$.get("coldfusion-page.cfm",function(data){
    $("#displaydiv").html(data);
});

$.get 是一种简写方法,用于简单地检索给定的 URL。它后面的 function() 部分是对 Coldfusion 页面的请求完成时运行的部分。它所做的只是将返回的数据放入 ID 为“displaydiv”的 HTML 标记中。

确实没有比这更简单的了。

I assume you have a fair knowledge of HTML. To accomplish the sort of thing you are asking, use this snippet:

$.get("coldfusion-page.cfm",function(data){
    $("#displaydiv").html(data);
});

$.get is a shorthand method that simply retrieves the given URL. The function() part that follows it is what is run when the request to the coldfusion page completes. All it does is put the data that came back into the HTML tag with an ID of "displaydiv".

It really doesn't get simpler than this.

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