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

cfajaxproxy throw new SyntaxError("parseJSON")

New Here ,
May 07, 2010 May 07, 2010

Copy link to clipboard

Copied

Hey guys, this time with some troubles i can't fix.. basically i have 2 files:

fleet.cfc

<cfcomponent>
    <cffunction name="FindFleet" access="remote" returnFormat="json" output="false">
      <cfargument name="cli_id" type="numeric" required="no" default="1">
      <cfquery name="qry_allVehData" datasource="#application.datasource#">
        SELECT *
        FROM tbl_vehicles
      </cfquery>

      <cfreturn qry_allVehData>
    </cffunction>
</cfcomponent>

myList.cfm

<cfajaxproxy cfc="fleet" jsclassname="emp">

<script type="text/javascript">
    Array.prototype.findIdx = function(value){
        for (var i=0; i < this.length; i++) {
            if (this == value) {
                return i;
            }
        }
    }
   
    var FindFleet = function(){
        var e = new emp();
        e.setCallbackHandler(populateFleet);
        e.setErrorHandler(myErrorHandler);
        e.FindFleet();
    }
   
    var populateFleet = function(fleet){
        with(document.simpleAJAX){
            var option = new Option();
           
            option.text = 'Choose a vehicle';
            option.value = '0';
            sel_vehicle.options[0] = option;
           
            for(i=0;i<res.DATA.length;i++){
                var option = new Option();
                option.text = fleet.DATA[fleet.COLUMNS.fixIdx('veh_desc')] + ' (' + fleet.DATA[fleet.COLUMNS.fixIdx('veh_pat')] + ') ';
                option.value = fleet.DATA[fleet.COLUMNS.fixIdx('veh_id')];
                sel_vehicle.options[i+1] = option;
            }
        }
    }
   
    var myErrorHandler = function(statusCode, statusMsg){
        alert('Status: ' + statusCode + ', ' + statusMsg);
    }
</script>

<form name="simpleAJAX" method="get">
  Vehicles:   
  <select name="sel_vehicle">
      <script language="javascript">
          FindFleet();
      </script>
  </select>
  <br><br>
</form>

When i call myList.cfm i'm getting this new SyntaxError("parseJSON"); for cfajax.js  (line 803) in firebug 1.5.3 when i check that line i have this, my Coldfusion Server is installed in an Ubuntu 9.10 Server with Apache2 and i refer to the CFIDE folder using a symbolic link (sudo ln -s /var/www/cfide CFIDE from inside the folder where my application resides).

Ne help on how can i fix this error?

TOPICS
Advanced techniques

Views

5.2K

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 ,
May 10, 2010 May 10, 2010

Copy link to clipboard

Copied

Bump!

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
New Here ,
May 11, 2010 May 11, 2010

Copy link to clipboard

Copied

Come on.!! is this error THAT hard to fix?

Some expert out there that can at least confirm if this is a bug or not?

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
New Here ,
May 12, 2010 May 12, 2010

Copy link to clipboard

Copied

Just discovered what was goin on with this error and it looks like a bug so i reported it to http://cfbugs.adobe.com with the ID 82852.

Basically u need this:

header.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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Document</title>

footer.cfm


</body>
</html>

index.cfm with some code that makes use of cfajaxproxy... for example (this should happen with any cf tag that makes use of ajax, even using something like <cfselect name="veh_id" bind="cfc:fleet.getFleet()" bindonload="yes"/> can make the bug to happen.

Application.cfc

<cfcomponent output="false">
     <cfset this.name = "ScheduledTasks">
     <cfset this.sessionmanagement = "yes">
     <cfset this.loginstorage = "session">
     <cfset this.setcookieclient = "true">
     <cfset this.sessiontimeout = #CreateTimeSpan(0,0,20,0)#>
     <cfset this.applicationtimeOut = #CreateTimeSpan(0,8,0,0)#>
  <cfset this.datasource = "ScheduledTasks">

  <cffunction name="OnApplicationStart" output="false">
    <cflock scope="Application" timeout="10" type="exclusive">
      <cfset application.datasource = "globalGPS">
      <cfset application.title = "ScheduledTasks">
      <cfset application.sessions = 0>
      <cfset application.base_Path = getDirectoryFromPath(getCurrentTemplatePath())>

       <cfswitch expression="#MID(cgi.server_software,1,(find("/",cgi.server_software) - 1))#">
          <cfcase value="APACHE">
               <cfset application.sourceRPT = application.base_Path & "reports/">
               <cfset application.sourceXML = application.base_Path & "data/">
               <cfset application.rawImgPath = application.base_Path & "images/">
          </cfcase>
          <cfdefaultcase>
               <cfset application.sourceRPT = application.base_Path & "reports\">
               <cfset application.sourceXML = application.base_Path & "data\">
               <cfset application.rawImgPath = application.base_Path & "images\">
          </cfdefaultcase>
       </cfswitch>

    
       <cfset application.development = true>
       <cfset application.server = cgi.server_software>
    </cflock>
  
    <cfset setlocale("Spanish (Modern)")>
    <cfcontent type="text/html;charset=iso-8859-1">
  
    <cfscript>
      setEncoding("FORM","iso-8859-1");
      setEncoding("FORM","iso-8859-1");
    </cfscript>
  
    <cflog type="information"
      file="#this.name#"
      date="yes"
      time="yes"
      text="The application #this.name# has been started.">
  
    <cfdirectory action="list" directory=#application.base_Path# filter="*.cfm" name="directoryFiles">
     </cffunction>

<cffunction name="OnRequestStart">
    <cfargument name="request" required="true"/>
        
    <cfscript>
      SetLocale("Spanish (Modern)");
    </cfscript>
        
    <cfinclude template="header.cfm">

  </cffunction>

  <cffunction name="OnRequestEnd">
    <cfinclude template="footer.cfm">
  </cffunction>

  <cffunction name="onSessionStart">
    <cfscript>
      Session.started = now();
    </cfscript>
    <cflock timeout="5" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
      <cfset Application.sessions = Application.sessions + 1>
    </cflock>
    <cflog file="#This.Name#"
      type="Information"
      text= "Session: #Session.sessionid# started.">
  </cffunction>

  <cffunction name="onSessionEnd">
    <cfargument name="SessionScope" required="yes">
  
    <cflog file="#This.Name#"
      type="Information"
      text="Session:  #arguments.sessionScope.sessionid# ended.">
    <cflogout>
  
    <cflock scope="session" type="exclusive" timeout="10">
      <cfset StructClear(Session)>
    </cflock>
  </cffunction>

  <cffunction name="onApplicationEnd">
    <cfargument name="ApplicationScope" required="true"/>
  
    <cflog file="#This.Name#"
      type="information"
      date="yes"
      time="yes"
      text="Application #Arguments.ApplicationScope.applicationname# ended">
    <cfset StructClear(Application)>
  </cffunction>
</cfcomponent>

If you run my code, you will see that new SyntaxError("parseJSON"); for cfajax.js  (line 803) will happen, and if you comment both includes i will work. I had tryed this on Linux and Windows OS with Apache2 and IIS... and guess what... SAME ERROR! , ne1 want's to confirm this and help me find a workarround?. Remove those cfinclude is not a option since i will be having to alter almost 50 templates.

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
Explorer ,
Aug 18, 2010 Aug 18, 2010

Copy link to clipboard

Copied

Any word on this?

I am getting this error trying to do an autosuggest.

Error: parseJSON
Source File: https://www.sacc.com/CFIDE/scripts/ajax/package/cfajax.js
Line: 803

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
Explorer ,
Aug 18, 2010 Aug 18, 2010

Copy link to clipboard

Copied

LATEST

I found out the the cfinclude at the beginning of my cfc was outputting

an html comment and that was being returned with my JSON. Ergo, parseJSON error.

I removed the cfoutput from the file being cfincluded and voila, no more parseJSON error.

The Net tab in the firebug debug window was really helpful once I knew what I was looking for.

The XHR tab shows all of the information being passed in ajax including request and response.

The response tab, having expanded the URL shows the information that you are getting back.

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