Hi, all...

I've been trying to wrap my head around using CF-jQuery-AJAX for awhile,
but just can't seem to get anything working.

I've looked at examples everywhere...on 365labs.net and the tutorial,
"Quickstart Guide to ColdFusion+jQuery Ajax" to the jQuery site, itself,
and also the AJAX_CFC site by Rob Gonda.

The "Quickstart..." tutorial, mentioned above, got me close, but I can't 
figure out the error I'm getting
and how to fix it.  I'm using Firebug, but I don't know how to respond 
to the feedback
it's providing.

Let me just ask this straight up:  Is there a "complete" tutorial, with 
*every* single character
of code provided, including the HTML, etc., that I can walk through and 
get working?
If I can find such a tutorial, I'm can change out the parts with my own 
and begin to understand
and make Ajax work.

(Or perhaps someone would be interested in coding a *complete* working 
example for a wishlist gift?
Christmas is coming, you know... :o)

I'd really *love* to find a simple "login" form that checks email and 
password against a database.
I find a *lot* of examples how to use PHP and jQuery to do that, but I 
need jQuery and ColdFusion.

By the way..has Ajax_CFC been abandoned?  All the info is from 2007 and 
is over a year old...

Now, if anyone can provide a link to an online tutorial such described 
above that would be great.

I'm also going to provide all the code I'm using for the "Quickstart 
Guide to ColdFusion+jQuery Ajax"
that is currently throwing an error, and include the Firebug error 
messages if anyone cares to go
beyond this point in this email.

Thanks for any help!

Rick


Here's the code for all the pages involved with Rob's tutorial, 
including Firebug's error messages, if
anyone cares to look at it...




When I run my html page (dinner.cfm), I select a day, but nothing happens.
(btw, the demo for this tutorial is at:


In the Firebug console, I'm getting these messages.

When I select the day from the input Firebug responds:

X 1 Error

"POST 
http://localhost/wsm-dev/jquery/jquery_cf_ajax/request_processor.cfm";     
jquery.js (line 1)
X invalid flag after regular expression     jquery.js (line 110)
</td></td></td></th></th></th></tr></tr>...></dir></div</div></dl></em></fig></fn>
 


Then when I click on "POST http://localhost..."; etc., to view the 
Headers/Post/Response tabs messages,
under Post I get "idm 2", which looks right...
under Reponse I get


Firebug needs to POST to the server to get this information for url:
*http://localhost/wsm-dev/jquery/jquery_cf_ajax/request_processor.cfm*

"This second POST can interfere with some sites. If you want to send the 
POST again, open a new tab in Firefox, use URL 'about:config', set 
boolean value 'extensions.firebug.allowDoublePost' to true "
"This value is reset every time you restart Firefox This problem will 
disappear when https://bugzilla.mozilla.org/show_bug.cgi?id=430155 is 
shipped."



Then below that text, when I click the "Load Reponse" button, I see:

{"main_dish":"Spaghetti","day":"Tuesday"}

which looks correct...


Here are the files I'm using:

dinner.cfm 
_______________________________________________________________________________ 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
    
<html xmlns="http://www.w3.org/1999/xhtml";>

<cfsetting showdebugoutput="no">

<head>

    <script language="JavaScript" 
src="http://www.365labs.net/cf_jquery/jquery.js"; 
type="text/javascript"></script>
    
    <script type="text/javascript">
    
        $(document).ready(function(){            
            $('#contentdiv').html('&nbsp;');
           
                $("#idm").change(function(){
                    var formval = { idm:$(this).val()};
               
                    $.ajax({
                                  type: "POST",
                                  url: "request_processor.cfm",
                                  dataType: "json",
                                  data: formval,
                                  success: function(response){
                                                              
$('#contentdiv').fadeIn(2000).append(response.MAIN_DISH);
                                                              }
                            });       
                });           
        });
       
    </script>
    
    
    <style type="text/css">
    
         body         { font-family: Arial, Helvetica, sans-serif; }
         #databox     { border: 1px solid Gray;                        
margin:30px auto 0px auto;
                       padding: 10px;                        width: 200px;}
        #contentdiv { color:red; font-size: 30px;  margin-top: 10px;}
       
    </style>
    
</head>

<body>

    <div align="center" id="databox">
    
        <select id="idm">
            <option value="0" SELECTED>What's for Dinner?...</option>
            <option value="1">Monday</option>
            <option value="2">Tuesday</option>
            <option value="3">Wednesday</option>
            <option value="4">Thursday</option>
            <option value="5">Friday</option>
            <option value="6">Saturday</option>
        </select>
               
        <p id="contentdiv"> </p>
       
    </div>
    
    
    
    
</body>

</html>




request_processor.cfm 
___________________________________________________________________________________
 


    <cfset odata = createObject("component","menudata")>
    <cfset thedata = odata.getmenuData(FORM.idm)>
    <cfset ojson = createObject("component","cfjson")>
    <cfset theresults = ojson.encode(thedata)>
    <cfoutput>#theresults#</cfoutput>




menudata.cfc 
___________________________________________________________________________________________
 


<cfcomponent displayname="menudata" hint="Contains database query" 
output="false">

    <cffunction name = "getMenuData">
    
        <cfargument name = "menu_id" required="yes">
       
        <cfquery name="get_menu" datasource="menudb">
       
            select          menu.day, menu.main_dish
            from          menu
            where        menu.qsid = #arguments.menu_id#
           
        </cfquery>
       
        <cfset pstruct = structNew()>
        <cfset pstruct.day = get_menu.day>
        <cfset pstruct.main_dish = get_menu.main_dish>
       
        <cfreturn pstruct>
       
    </cffunction>

</cfcomponent>




cfjson.cfc 
_____________________________________________________________________________________________________
 



(I won't replicate that here...)


Can you spot where I'm going wrong?
I can put my attempt online if that would help...


Thanks for the help!

Rick


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:316385
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to