Patrick
Patrick

Reputation: 2577

Returning css formatted coldfusion results with jquery

Okay, so I did this jquery, and the results come back fine, but the css doesn't get applied. Is there a way to apply css to the results?

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 - This is the div that gets the new contents

<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>

The results returned from the AJAX call look like this

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

So it's literally replacing one thing with the exact same thing. My calling page has a in the title.

Upvotes: 1

Views: 56

Answers (1)

Henry
Henry

Reputation: 32915

The ajax call looks like it is returning HTML from CF. So basically, you have 2 options.

  1. generate the css inside a <style> tag and return it along side with your query table.
  2. include the css file in your caller page, and make sure the generated result from your .cfm uses the same predefined classes.

Upvotes: 5

Related Questions