Hi All, I am trying to get data back from the server by passing JSON values from jQuery. Find below my code:
$("#btn").click(function() { $.ajax({ url: "http://" + location.host + "/AJAXSample/ GenericHandler.ashx", data: {name: 'Ted'}, type: "GET", dataType: "json", success: function(data) { var myarray = eval('(' + data.responseText + ')'); alert('Hello ' + myarray.Result); }, error: function(xhr) { alert('Error: ' + xhr.status + ' ' + xhr.statusText + ' ' + xhr.responseText); } }); return false; }); My server side code is: string myData = context.Request.Params["name"]; context.Response.ContentType = "text/plain"; string myVal = "{ 'Result' : '" + myData + "' }"; context.Response.Write(myVal); I am just trying to return JSON data from server. It is returning data but in alert box of success method it shows 'undefined'. Can anyone let me know where am i making a mistake. This is just sample & I will use this logic to return complex data from server in further apps.