Highlighted

How do you pass "struct" in an AJAX call URL? (CF11)

New Here ,
Jul 28, 2014

Copy link to clipboard

Copied

Quote from CF11 documentation: "Note that "struct" is also available to be accessible through an AJAX argument. Now you can pass struct  in an AJAX URL to serialize a query object as struct."

How? An example URL would be handy.

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

"To serialize a query object as struct" overstates the case. You can serialize a struct, as well as a query, for sending by means of URL.

For example, create the following 2 CFM pages in the same directory.

testpage1.cfm

<cfdump var="#url#">

testpage2.cfm

<cfset myStruct = structnew()>

<cfset myStruct.myFirstKey = "uno">

<cfset myStruct.mySecondKey = 2>

<cfset myStructSerialized = serializeJSON(myStruct)>

<!--- Uses built-in cfdocexamples datasource --->

<cfquery name = "getBiololgyCourses" dataSource = "cfdocexamples">

    SELECT Course_ID, Dept_ID, CorNumber,

    CorName, CorLevel

    FROM CourseList

    WHERE Dept_ID = 'BIOL'

    ORDER by CorNumber asc

</cfquery>

<cfset biologyCoursesSerialized = serializeJSON(getBiololgyCourses)>

<cflocation url="testpage1.cfm?myVar=#myStructSerialized#&biologyCourses=#biologyCoursesSerialized#">

Views

330

Likes

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

How do you pass "struct" in an AJAX call URL? (CF11)

New Here ,
Jul 28, 2014

Copy link to clipboard

Copied

Quote from CF11 documentation: "Note that "struct" is also available to be accessible through an AJAX argument. Now you can pass struct  in an AJAX URL to serialize a query object as struct."

How? An example URL would be handy.

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

"To serialize a query object as struct" overstates the case. You can serialize a struct, as well as a query, for sending by means of URL.

For example, create the following 2 CFM pages in the same directory.

testpage1.cfm

<cfdump var="#url#">

testpage2.cfm

<cfset myStruct = structnew()>

<cfset myStruct.myFirstKey = "uno">

<cfset myStruct.mySecondKey = 2>

<cfset myStructSerialized = serializeJSON(myStruct)>

<!--- Uses built-in cfdocexamples datasource --->

<cfquery name = "getBiololgyCourses" dataSource = "cfdocexamples">

    SELECT Course_ID, Dept_ID, CorNumber,

    CorName, CorLevel

    FROM CourseList

    WHERE Dept_ID = 'BIOL'

    ORDER by CorNumber asc

</cfquery>

<cfset biologyCoursesSerialized = serializeJSON(getBiololgyCourses)>

<cflocation url="testpage1.cfm?myVar=#myStructSerialized#&biologyCourses=#biologyCoursesSerialized#">

Views

331

Likes

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
Jul 28, 2014 0
Adobe Community Professional ,
Jul 29, 2014

Copy link to clipboard

Copied

"To serialize a query object as struct" overstates the case. You can serialize a struct, as well as a query, for sending by means of URL.

For example, create the following 2 CFM pages in the same directory.

testpage1.cfm

<cfdump var="#url#">

testpage2.cfm

<cfset myStruct = structnew()>

<cfset myStruct.myFirstKey = "uno">

<cfset myStruct.mySecondKey = 2>

<cfset myStructSerialized = serializeJSON(myStruct)>

<!--- Uses built-in cfdocexamples datasource --->

<cfquery name = "getBiololgyCourses" dataSource = "cfdocexamples">

    SELECT Course_ID, Dept_ID, CorNumber,

    CorName, CorLevel

    FROM CourseList

    WHERE Dept_ID = 'BIOL'

    ORDER by CorNumber asc

</cfquery>

<cfset biologyCoursesSerialized = serializeJSON(getBiololgyCourses)>

<cflocation url="testpage1.cfm?myVar=#myStructSerialized#&biologyCourses=#biologyCoursesSerialized#">

Likes

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
Reply
Loading...
Jul 29, 2014 0