But what about returning a JSON object? (not just plain text) Like as i get more into jQuery and AJAX i'd like to return some more complicated objects from my aspx code
On Dec 8, 11:15 am, Tony <[EMAIL PROTECTED]> wrote: > Hi, > maybe you missed this > function SaveThis(key, val) { > $.post("/services/process/config.aspx", > { Key: key, Value : val }, > function(data){ > alert(data.responseText); > } > ); > > Tony > > On 8 Дек, 17:12, MorningZ <[EMAIL PROTECTED]> wrote: > > > Good morning all..... > > > I've got a call to an aspx page, nice and simple, the alerts are just > > to test: > > > function SaveThis(key, val) { > > $.post("/services/process/config.aspx", > > { Key: key, Value : val }, > > function(data){ > > alert(data); > > alert(data.Results); > > } > > ); > > > } > > > The alerts are just for testing obviously, but i am just keeping it > > simple > > > anyways, the "config.aspx" simply says: > > > Protected Sub Page_Load(ByVal sender As Object, ByVal e As > > System.EventArgs) Handles Me.Load > > Dim Results As String > > Try > > If _ConfigSettings.Set(Request.Form("Key"), > > Request.Form("Value")) > 0 Then > > Results = "Saved!" > > Else > > Results = "Error: not saved" > > End If > > Catch ex As Exception > > Results = "Error: " & ex.Message > > End Try > > Response.Clear() > > Response.Cache.SetCacheability(HttpCacheability.NoCache) > > Response.ContentType = "text/plain" > > Response.Write(String.Format("{ ""Results"" : ""{0}"" }", > > Results)) > > Response.Flush() > > End Sub > > > So i am trying to return in plain text this: > > > { "Results" : "Saved!" } > > > But the second alert in my jQuery block says "null" for data.Results > > > I am missing something? > > > Also, i know about that class that someone made to turn a .NET class > > into a JSON object, but i am just after simple results to start > > with... > > > Thanks in advance > > - Stephen