$.ajax({ type: 'POST', url: "Default.aspx/SetSession", data: '{ "name" : "' + name + '" }', contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (msg) { alert(JSON.parse(msg.d)); }, error: function (msg) { alert(msg.responseText); }