Please see the AJAX below:
What am I doing wrong?
Try setting dataType to json instead of text:
dataType: 'json'
And then send the javascript object as a JSON string in the id parameter:
window.location.href("JSONExample.aspx?id=" + encodeURIComponent(JSON.stringify(response.d)));
Notice that we are using response.d here because ASP.NET WebMethods serialize the responses using this special property.
Also you probably want to use public properties instead of fields for your model:
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
Some frameworks choke on fields.