With jquery, no you can call a .cfm page. You just have to make sure the data 
is in the proper format. Here's an example where what's returned is just plain 
html:

<s/cript>
$('.subMenuItem').live('click', function() {
        var thelink = $(this);
        var theURL = thelink.attr('href');
        $("#contentDiv").load(theURL);
        return false;
});

</s/cript>

Basically what happens here is that you're telling jQuery that whenever a user 
clicks on something with a subMenuItem class, you want to extract the value of 
the href attribute. Then do an ajax call to the href value (in this case 
vendors.cfm but it could also have been to a cfc). The final step inserts the 
returned information into the html of the contentDiv. 

In my vendors.cfm template there is a simple query and some html layout 
(basically a list of links), but it could have also been json data, xml or 
javascript. This setup is very similar to what is done with a binding on CFDiv.

With what you want, I'd have the page return json, then in the javascript 
function build what you want from the returned json.

Ben Nadel and Ray Camden have both written a lot on how to use jQuery with 
Coldfusion. You may want to check out their blogs for articles on the topic.

hth,
larry


>Hi Craig et al
>
>Thanks for this
>
>So download JQuery and link to the file on your server
>
>Does it have to be a CFC?  Its just that I have never used them before -
>where would your SQL go in the CFC and would it be the same as a cfm
>page 
>
>i.e.
><cfquery> select * from emptable where employeenumber =
>#form.employeenumber# </cfquery>
>
>
>Then after you have queried the database - how would you populate the
>form fields on the fly with the data you extracted from the database
>based on what employee number had been entered
>
>For example I take it that 
><cfinput type="text" id="empname"  name="empname"
>value="#queryperson.empname#" .....
>
>
>Would not work?
>
>
>Basically the easiest way to do ajax, is the following...
>
>1. download jquery libraries, or in your source code refer to different
>hosting of the jquery libraries. jquery fyi, is javascript libraries,
>that work cross-browser and make it easier to do things like ajax, and
>millions of other things.
>
>2. Read this and any other article,
>http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-ca
>lls-with-jquery/ to get a handle on how to use jquery.
>
>3. create a cfc, that can send/receive data you want.
>
>Yes this is a lot to learn, if you've never played with ajax or jquery
>before. So I will show you some example code.
>
>You can either download a copy of the jquery libraries, or refer to a
>cdn hosted copy on google or jquery.com, or a few other sites hosting
>jquery libraries for public use.
>
>Then you need to create a cfc, which is basically like a coldfusion
>normal template, except it has functions, instead of normal page logic.
>
>A cfc will be like this structure
>
>cfcomponent
>
>cffunction name="somename" access="remote" output="true"
>cfargument name=company_id type=integer required=true
>
>do some stuff
>
>/cffunction
>
>/cfcomponent
>
>That's a very basic cfc, must be saved as a cfc extension.
>
>The 1st key part is making the cfc file in a web-accessible url folder.
>
>Then you have to create ajax that will send the parameters it needs to
>do whatever functioning you need to do.
>
>I hope this get's you a good starting point....
>
>
>>Hi
>>
>>We are on CF7, not sure if this restricts the amount of functionality
>>available to me?
>>
>>So how would it work - when a user types in their employee number in
>the
>on
>>
>>your server passing entered employee number as data/argument, which
>will 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342731
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to