• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Getting throw new SyntaxError("parseJSON"); cfajax.js (line 803)

Guest
Jul 08, 2011 Jul 08, 2011

Copy link to clipboard

Copied

First of all, I have looked through forums and have found others with similar problems, but i have tested all their recommendations and still no success.  So i'm hoping someone can help. I'll try to provide as much information as possible.

So being new to working with Ajax, im trying to make an ajax call from a .cfm to a .cfc using cfajaxproxy, which is where i keep getting this error.  My cfm is a form that produces a checklist based on the user.  As each checkbox is checked, i want a call to the cfc to run a function, make queries etc.  As of right now, when the user selects a check box the information is being passed to the javascript, but there is no response from the cfc function and i keep getting the mentioned error in firebug.

-I have tried creating a copy of my cfc in the wwwroot folder and giving it blank data (cffunction named whatever, cfargument named nothing set to  "") and use the extends parameter pointing to the out-of-root CFC, but that doesnt work

http://forums.adobe.com/message/3683967#3683967

-There is nothing outputting any html comment in my cfc as mentioned in

http://forums.adobe.com/message/2796016#2796016

.cfm

<cfajaxproxy cfc="orientation_funcs" jsclassname="orientation_funcs" />
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>   
        <link rel="stylesheet" type="text/css" href="orientation.css" />
        <title>Ryerson Orientation - Main Page</title>
       
        <script type="text/javascript">       
                function updateEvent(eventId){
                var instance = new orientation_funcs();
                alert(eventId);       
                instance.test(eventId);
                alert("after calling the method");
            }
        </script>

     ............

     .......

<cfform action="orientation_login_process.cfm" method="POST">
                <cfoutput query="scheduleOfEvents">
                    <!--- Table displaying the various orientation events available to the student --->
                    <table class="center">

                    ..............

                    ...................

                    <td style="width:5%;">
                                <cfinput type="checkbox" id="eventSelect_#event_Id#" name="eventSelect" value="#event_id#" onclick="updateEvent(#event_id#)">
                            </td>
                            <!--- <cfif #completed# is 'F'>
                                <td style="width:5%;">
                                    <cfinput type="checkbox" name="eventSelect" value="#event_id#">
                                </td>
                            <cfelseif #completed# is 'T'>
                                <td style="width:5%;">
                                    <cfinput type="checkbox" name="eventSelect" value="#event_id#" checked="True" readonly="true">
                                </td>
                            </cfif> --->
                        </tr>
                    </table>
                </cfoutput>  
            <cfinput type="submit" name="Save" value="Save Progress">
            </cfform>       
       
    </head>
    <body>

.cfc (in the same folder as the .cfm)

<cfcomponent displayname="orientation_funcs"
             hint=""
             output="false">

<cffunction name="test" access="remote" output="false" returnFormat="JSON" hint="">
        <cfargument name="ev" type="string" required="yes">
          <script>

               alert("inside cfc function");

          </script>

</cffunction>


.cfc (in the wwwroot folder)

<cfcomponent displayname="orientation_funcs"
             hint=""
             extends="Orientation_App.orientation_funcs"
             output="false">

  <cffunction name="whatever" access="remote" hint="" >
        <cfargument name="nothing" default="">
    </cffunction>  
</cfcomponent>

So what happens now is, when i select the checkbox on the form, the initial alert message in updateEvent(eventID) function appears, but the message inside the cfc function does not get produced.  In firebug, the "throw new SyntaxError("parseJSON"); appears.  Any help or suggestions would be greatly appreciated and thanks in advance.

TOPICS
Advanced techniques

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2011 Aug 14, 2011

Copy link to clipboard

Copied

I am one of the millions of people with the same issue.  Did you find your solution?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 14, 2011 Aug 14, 2011

Copy link to clipboard

Copied

You can't expect an alert() being called in side the CFC to pop-up on your client browser's screen: the call to the CFC is executing code on the ColdFusion server, not in the client browser.  So the fact you're not seeing it is meaningless (and predictable).

If you want to check that your CFC method is being called, put a CFLOG call in it or something.

As for your AJAX error, my initial guess would be it's occuring because the JS/CF proxy expects you to return some JSON from your method, and you ain't returning squat.  This is just - as I say - a guess though.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 14, 2011 Aug 14, 2011

Copy link to clipboard

Copied

LATEST

Oh, and have you looked at what's going on @ line 803 of cfajax.js?  It might cast light on the scene as to why your code ain't working.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation