I am new at json, I want to make jquery ajax call to a asp.net webmethod to get back simple JSON object using string builder
[WebMethod]
public static string GetmyJSON()
{
StringBuilder sb = new StringBuilder();
sb.Append("{firstname: \"Manas\",").Append("lastname : \"Tunga\"").Append("}");
return sb.ToString();
}
In my Clint side code i have written
.ajax({
type: "POST",
url: "simplePage.aspx/GetmyJSON",
data: "{}",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (data) {
alert(data.d.firstname); //only showing undefined insted of Manas
} // end of sucess
}); // End of ajax
But My alert message showing undefined instead of Manas why, Where I am doing wrong isn't possible to return a json object using string builder ??? if possible how to write it.