So I searched through most of the getJSON questions and am still unable to find a solution to my problem. My main problem is this: I have a .js file that makes a $.getJSON call to an .aspx page. The .aspx page returns a json object. I've tested the $.getJSON with a demo.js and it works just fine; I'm able to reference the json field. This is not the case with the .aspx page. Here is my code:
.js making the $getJSON call
$.getJSON('updateSlides.aspx', function (json) {
alert("JSON Data: " + json.url);
});
.aspx returning json obj
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim jsonString As String
If Not Page.IsPostBack Then
Dim ws As New wallboardSettings
' pull data values from db here, replace hardcoded values below
ws.duration = 5
ws.imagePath = "Images\slide1.jpg"
ws.url = "slide1.html"
Dim js As JavaScriptSerializer = New JavaScriptSerializer()
jsonString = js.Serialize(ws)
Response.Write(jsonString)
End If
End Sub
I've placed a msgbox in the VB and ran it from my local machine to see my values. It returns the ws property settings in json form, which validated correctly on jsonlint.com.
I've also tried just using an $.ajax call with async: false but it doesn't work. When I use the demo.js, which works, i see the json fields in firebug; this is not the case with the updateSlides.aspx.
Thanks in advance, Brian