Skip navigation
Currently Being Moderated

cfajaxproxy throw new SyntaxError("parseJSON")

May 7, 2010 3:20 PM

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[i] == 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[i][fleet.COLUMNS.fixIdx('veh_desc')] + ' (' + fleet.DATA[i][fleet.COLUMNS.fixIdx('veh_pat')] + ') ';
                option.value = fleet.DATA[i][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?

 
Replies
  • Currently Being Moderated
    Aug 18, 2010 3:44 AM   in reply to Rodrigo Alarcon

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 18, 2010 4:34 AM   in reply to Dave Miller

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points