【问题标题】:Returning css formatted coldfusion results with jquery使用 jquery 返回 css 格式的冷融合结果
【发布时间】:2014-08-05 20:45:15
【问题描述】:

好的,所以我做了这个 jquery,结果很好,但是 css 没有得到应用。有没有办法将 css 应用于结果?

function doSearch() {
//Send the AJAX call to the server
  $.ajax({
  //The URL to process the request
    'url' : 'cf/inventoryQuery.cfm',
  //The type of request, also known as the "method" in HTML forms
  //Can be 'GET' or 'POST'
    'type' : 'POST',
  //Any post-data/get-data parameters
  //This is optional
    'data' : $("#SearchInventory").serialize(),
  //The response from the server
    'success' : function(data) {
        $('#Results').html(data);
    }
  });
}

EDIT - 这是获取新内容的 div

<div id="Results" >
    <cfoutput query="queryCars" maxrows="4">
        <div class="Result">
            <img src="images/samplecar.png"  />
            <div class="ResultText">
               #strYear# #strMake# #strModel#
        </div>
        </div>
    </cfoutput>
</div>

AJAX 调用返回的结果如下所示

    <cfoutput query="queryCars" maxrows="4">
        <div class="Result">
            <img src="images/samplecar.png"  />
            <div class="ResultText">
                #strYear# #strMake# #strModel#
         </div>
        </div>
    </cfoutput>

所以它实际上是用完全相同的东西代替一件事。我的呼叫页面有一个 在标题中。

【问题讨论】:

    标签: jquery css coldfusion


    【解决方案1】:

    ajax 调用看起来像是从 CF 返回 HTML。所以基本上,你有两个选择。

    1. &lt;style&gt; 标记内生成 css 并将其与查询表一起返回。
    2. 在调用者页面中包含 css 文件,并确保从 .cfm 生成的结果使用相同的预定义类。

    【讨论】:

    • 这就是令人困惑的事情 - 调用它的页面正在用新的查询结果替换一个 div - 放在 div 内的项目具有所有相同的类。
    • 我像你推荐的那样包含了样式标签。效果很好。
    猜你喜欢
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多