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

Ajax Proxy Error

Explorer ,
Feb 04, 2012 Feb 04, 2012

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,"KhayberPaktoonKha"],[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&argumentCollection=%7B%7D&_cf_nodebug=true&_cf_nocache=true&_cf_clientid=D6347871AEC0896D1D0965740EA2C089&_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

TOPICS
Advanced techniques
3.4K
Translate
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

correct answers 1 Correct answer

Community Expert , Feb 08, 2012 Feb 08, 2012

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>

Translate
Community Expert ,
Feb 07, 2012 Feb 07, 2012

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>

Translate
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 ,
Feb 08, 2012 Feb 08, 2012

Hello

I tried it, no difference but I noticed one strange thing I have a sitefooter.cfm it contans

<A href="index.cfm">Who We Are</A> |

            <A href="SiteMap.cfm">Site Map</A> |

            <A href="privacy.cfm">Privacy Policy</A> |

            <A href="contact.cfm">Contact Us</A>

            <BR>Developed by Tayab Hussain </DIV>

                              </TD>

                    </TR>

          </TABLE>

</TD>

</TR>

</TBODY>

</TABLE>

This is called in application.cfc

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

<!--- Display our Site Footer at bottom of every page --->

<cfinclude template="SiteFooter.cfm">

          </cffunction>

When I comment out the <cfinclude template="SiteFooter.cfm"> it works and there is no error. What I think, but, cannot work out how to, is the application.cfc adds DOCTYPE html element to every request served by CF. This also includes JSON requests to places.cfc. However HTML code in JSON replies is a syntax error, and replies cannot be parsed. In other words I must ensure that replies from cfselect bind functions are pure JSON without any additions, even whitespaces will brake things. Please do comment

Translate
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
Community Expert ,
Feb 08, 2012 Feb 08, 2012

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.

Translate
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 ,
Feb 08, 2012 Feb 08, 2012

That was quick, so how should I code he footer?

Translate
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
Community Expert ,
Feb 08, 2012 Feb 08, 2012

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>

Translate
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 ,
Feb 08, 2012 Feb 08, 2012
LATEST

Thanks, it worked

Translate
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