Skip navigation
Currently Being Moderated

Ajax Proxy Error

Feb 4, 2012 10:44 AM

I need help on this error

 

window:global: Uncaught SyntaxError: parseJSON (http://localhost/CFIDE/scripts/ajax/package/cfajax.js, line 803)

info:http: CFC invocation response: {"COLUMNS":["ID","PROVINCE"],"DATA":[[1.0,"Punjab"],[2.0,"KhayberPakt oonKha"],[3.0,"Sindh"],[4.0,"Baluchistan"]]} Who We Are | Site Map |Privacy Policy | Contact Us
Developed by Tayab Hussain

info:http: HTTP GET /eco/Places.cfc?method=Getprovince&returnFormat=json&argumentCollecti on=%7B%7D&_cf_nodebug=true&_cf_nocache=true&_cf_clientid=D6347871AEC08 96D1D0965740EA2C089&_cf_rc=0

info:http: Invoking CFC: /eco/Places.cfc , function: Getprovince , arguments: {}

info:LogReader: LogReader initialized

info:global: Logger initialized

 

This occured when I tried Related select and wanted to bind Provinces with Cities

 

The Places.cfc code is

<cfcomponent>

    <cffunction name="Getprovince" access="remote" returnType="any">

        <cfquery name="Lstprovince">

            SELECT Id, province

            FROM province

            ORDER BY id

        </cfquery>

        <cfreturn Lstprovince>

    </cffunction>

      <cffunction name="GetCity" access="remote" returnType="any">

    <cfargument name="Province" type="any" required="true">

    <cfif ARGUMENTS.Province EQ "">

    <cfelse>

        <cfquery name="LstCity">

            SELECT Id, province_id, desp

            FROM city

            WHERE province_id = #ARGUMENTS.province#

            ORDER BY id

        </cfquery>

    </cfif>

    <cfreturn LstCity>

    </cffunction>

</cfcomponent>

 

Gettingstarted contains

 

<cfajaxproxy cfc="Places">

<TD>Province:<BR>

     <cfselect name="SelProvince" bind="cfc:Places.Getprovince()"

          display="Province" value="ID" BindOnLoad="true"/>

</TD>

<TD>City:<BR>

          <cfselect name="SelCity" bind="cfc:Places.GetCity({SelProvince})"

                              display="desp" value="Id"/>

</TD>

 

Please can any body help

 
Replies
  • Currently Being Moderated
    Feb 7, 2012 3:36 AM   in reply to Tayyab Hussain

    I think you are combining 2 idioms here, which are alternatives to each other. Comment out the line <cfajaxproxy cfc="Places">. Use just

     

    <cfform>

    Province:<BR>

    <cfselect name="SelProvince" bind="cfc:Places.Getprovince()"

              display="Province" value="ID" BindOnLoad="true"/>

    <BR>

    City:<BR>

              <cfselect name="SelCity" bind="cfc:Places.GetCity({SelProvince})"

                                  display="desp" value="Id"/>

    </cfform>

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 8, 2012 9:52 AM   in reply to Tayyab Hussain

    There you are then. Application.cfc adds the footer information to the JSON response. The footer information is non-JSON. Since ColdFusion automatically validates JSON responses when parsing them, the result is the error you saw.

     

    JSON:

    {"COLUMNS":["ID","PROVINCE"],"DATA":[[1.0,"Punjab"],[2.0,"KhayberPakt oonKha"],[3.0,"Sindh"],[4.0,"Baluchistan"]]}

     

    Non-JSON(causing error):

    Who We Are | Site Map |Privacy Policy | Contact Us

    Developed by Tayab Hussain

     

    Nevertheless, I would still leave out cfajaxproxy tag.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 8, 2012 10:07 AM   in reply to Tayyab Hussain

    Perhaps something like this:

     

    <cffunction name="onRequestEnd" returnType="void" output="true">

        <cfargument name="targetPage" type="string" required="true">         

       <cfif listLast(arguments.targetPage,".") neq "cfc">

            <cfinclude template="sitefooter.cfm">

        </cfif>

    </cffunction>

     
    |
    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