[jQuery] HttpHandler not returning JSON data

[jQuery] HttpHandler not returning JSON data


Hi All,
I was working with a basic example where I wanted to get JSON data
from the HttpHandler. My javascript code looks like:
$.ajax({
url: 'Handler1.ashx',
type: 'POST',
data: { name: 'MyName' },
contextType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(data) {
alert("Data Saved " + data.name);
}
});
My Handler1.ashx code looks like:
context.Response.ContentType = "application/json";
string results = "{ 'name': '"+ context.Request.Params["name"] +"' }";
context.Response.Write(results);
But I am not getting the results right. Infact I am not getting any
result in data.name. Please let me know what is the mistake and what
is the correct way to get JSON data.