/************BEGIN - Client side code*****************/ $(document).ready(function(){ $('#btnSubmit').click(function(){ // Below is an AJAX call which is throwing error. // $.ajax({ // type: "POST", // url: "CTypesHandler.ashx", // data: "{'fname':'"+$('#txtFirstName').val()+"'}", // contentType: "application/json; charset=utf-8", // dataType: "json", // success:function(msg){ // alert(msg.fname); // }, // error:function(xhr, status, errorThrown){ // alert('Error'+errorThrown); // } // }); //Below is similar AJAX call as above using $.POST and it works! $.post("CTypesHandler.ashx", { fname : $('#txtFirstName').val()},fnCallback,"json"); function fnCallback(response) { alert(response.fname); } }); }); /************END - Client side code*****************/ /************BEGIN - Server side code*****************/ <%@ WebHandler Language="VB" Class="CTypesHandler" %> Imports System Imports System.Web Imports Jayrock.Json Public Class CTypesHandler : Implements IHttpHandler Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim jsObj As New JsonObject Dim fname As String = "" Try fname = context.Request.Form("fname") jsObj("fname") = fname context.Response.ContentType = "application/json" context.Response.Write(jsObj) Catch ex As Exception context.Response.Write("hError") End Try End Sub Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property End Class /************END - Server side code*****************/