Glad you worked it out.
One thing you should do is make sure a session variable exists before using
the session variables.
When I first loaded the page I received an error, after I refreshed the
error went away.
You should cfparam the variables to a default first, otherwise they wont be
set until after you call the ajax request.
The success: function(){} is used to call back the data from the ajax
request, you could use those to dynamically set a div to the variable
returned.
Error Occurred While Processing Request
Element SCREENSIZE.WIDTH is undefined in SESSION.
On Sun, Dec 23, 2012 at 6:35 AM, The Dude <[email protected]> wrote:
>
> Thanks guys for the jquery pointer, much appreciated. Got it working so
> the data is now in cfml via ajax. Page source got numbers vs string. Doh !!
>
> http://exelstudio.com/test5.cfm
>
> jquery ajax call:
>
> <script type="text/javascript">
> var theData= "screenWidth=" + screen.width+
> "&screenHeight="+screen.height;
>
> $.ajax({
> type: "POST",
> url: "ajax.cfc?method=myMethod",
> data: theData,
> datatype: "json",
> success: function(){}
> });
> </script>
>
> ajax.cfc file:
>
> <cfcomponent>
> <cffunction name="myMethod" returntype="struct" access="remote"
> returnformat="json">
> <cfargument name="screenWidth" type="numeric" required="no">
> <cfargument name="screenHeight" type="numeric" required="no">
>
> <cflock scope="session" type="exclusive" timeout="30">
> <cfset session.screensize = StructNew()>
> <cfset session.screensize.width= #arguments.screenWidth# />
> <cfset session.screensize.height= #arguments.screenHeight# />
> </cflock>
>
> <cfreturn session.screensize>
> </cffunction>
> </cfcomponent>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:353640
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm