Solved

JQuery and CFC

Posted on 2014-10-08
3
234 Views
Last Modified: 2014-10-09
I have a jquery/CFC solution that does a lookup but I am getting

I get "Unsupported Operation. Check application log for more details. " when I try to include the result.    If I don't include the result, I get the else showing every time which makes sense since 1 doesn't work.   I am using the jquery date picker too with that field.

CFC:
<cfcomponent output="false">


    <cffunction name="getCoupon" access="remote" returnType="string">
        <cfargument name="classdate" type="string" required="true">

        <!--- Define variables --->
        <cfset var data="">
        <cfset var result="">

        <!--- Get data --->
        <CFQUERY NAME="getCoupon" datasource="ds">
	select couponcode from coupons where testdate1 = '#arguments.classdate#' or testdate2 = '#arguments.classdate#' or testdate3 = '#arguments.classdate#'
</CFQUERY>

    
        <!--- Got it? --->
        <cfif getCoupon.RecordCount eq 1>
            <cfset result=1>
            <CFELSEIF getCoupon.recordcount eq 0 and len(#arguments.classdate#)>
            <cfset result=2>
            <CFELSE>
            <CFSET result=0>
        </cfif>

        <!--- And return it --->
        <cfreturn result>
    </cffunction>

</cfcomponent>

Open in new window


Jquery:

 $(document).ready(function() {


		//result texts
	
		var checking_html = 'Checking...';

		//when button is clicked
		$('##datepicker').change(function(){

			$('##proctor_availability_result').html(checking_html);
				check_availability();
		});

  });

//function to check  availability
function check_availability(){

		//get the username
		var testdate = $('##datepicker').val();

		//use ajax to run the check
		$.post("testdate.cfc", { testdate: testdate },
			function(result){
				//if the result is 1
				if(result == 1){
					//show that the username is available
					$('##proctor_availability_result').html(result + 'You do not need to provide proctor information because you are sitting for your test at a scheduled location.');
				}else{
					//show that the username is NOT available
					$('##proctor_availability_result').html(result + 'You must complete proctor information prior to sitting for your exam but you do not need to complete this information to submit your registration.');
				}
		});

}
 

Open in new window


Form

<TR><TD valign="top"><strong>Test Date</strong><img src="RedStar.gif" width="10" height="16" alt="Required" border="0">:</TD><TD><input type="text" id="datepicker" readonly name="classdate" value="#dateformat(getreg.startdate, "mm/dd/yyyy")#"></TD></TR>

<TR><TD colspan="2"><div id='proctor_availability_result'></div></TD></TR>

Open in new window

0
Comment
Question by:digitalwise
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 40370350
Not that experienced with CF but in your code you seem to be using an argument called classdate but from jQuery you are passing an argument as testdate - is that a CF thing or should they be the same?
0
 

Author Closing Comment

by:digitalwise
ID: 40372032
You didn't actually provide me with the solution but you pushed me in another direction - I forgot to call the CFC Function in the jquery.   Thanks!
0
 
LVL 53

Expert Comment

by:Julian Hansen
ID: 40372318
You are welcome - thanks for the points and the grade. Have a great day.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now