network.request - Passing Multiple Variables in Response

Hi there,

Does anyone know how I would go about passing multiple variables back in the response from my network.request?

As I was used to doing when I used to develop for Flash, I tried passing back:

userId=1&operation=Edit&errorCode=0

…but how do I then access the values of userId, operation and errorCode? My event.response just gives that string, so event.response.userId gives nothing.

I’m aware I could simply pass back a string of values separated by commas (in this case it would be 1,‘Edit’,0) and then split those out but I’d like to be able to refer to each value by name rather than having to remember a list of values with no way of identifying which is which at first glance.

Thanks,

Ian

Okay - got it. Used json to encode the data in my .Net script before passing it back to my app and decoding…

local json = require "json" local t = json.decode( d ) local operation = t[1].operation; local userId = t[1].userId; local errorCode = t[1].errorCode;

Hope this helps someone else.

Here’s how I’m encoding it in .Net by the way…

\<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" debug="true" &nbsp; %\> \<%@ Import Namespace="System.IO" %\> \<%@ Import Namespace="System.Web.Script.Serialization" %\> \<Script Runat="Server"\> &nbsp; &nbsp; sub Page\_Load(Source As Object, E As EventArgs) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim saveDetails As New List(Of SaveDetails)() &nbsp; &nbsp; &nbsp; &nbsp; saveDetails.Add(New SaveDetails With {.operation = 0, .userId = 1, .errorCode = 0}) &nbsp; &nbsp; &nbsp; &nbsp; Dim serializer As New JavaScriptSerializer() &nbsp; &nbsp; &nbsp; &nbsp; Dim serializedResult = serializer.Serialize(saveDetails) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write(serializedResult) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;End Sub &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Public Class SaveDetails &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Public Property operation As Integer &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Public Property userId As Integer &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Public Property errorCode As Integer &nbsp;&nbsp;&nbsp;&nbsp;End Class \</Script\>

Okay - got it. Used json to encode the data in my .Net script before passing it back to my app and decoding…

local json = require "json" local t = json.decode( d ) local operation = t[1].operation; local userId = t[1].userId; local errorCode = t[1].errorCode;

Hope this helps someone else.

Here’s how I’m encoding it in .Net by the way…

\<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" debug="true" &nbsp; %\> \<%@ Import Namespace="System.IO" %\> \<%@ Import Namespace="System.Web.Script.Serialization" %\> \<Script Runat="Server"\> &nbsp; &nbsp; sub Page\_Load(Source As Object, E As EventArgs) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim saveDetails As New List(Of SaveDetails)() &nbsp; &nbsp; &nbsp; &nbsp; saveDetails.Add(New SaveDetails With {.operation = 0, .userId = 1, .errorCode = 0}) &nbsp; &nbsp; &nbsp; &nbsp; Dim serializer As New JavaScriptSerializer() &nbsp; &nbsp; &nbsp; &nbsp; Dim serializedResult = serializer.Serialize(saveDetails) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write(serializedResult) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;End Sub &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Public Class SaveDetails &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Public Property operation As Integer &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Public Property userId As Integer &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Public Property errorCode As Integer &nbsp;&nbsp;&nbsp;&nbsp;End Class \</Script\>