Get Values from Client Side to Server Side using jQuery

Get values from client side to server side using JQuery.

Declare 2 hidden field in client side :

<input type="hidden" value="0" id="hfUId" />
<asp:HiddenField ID="HiddenFieldUId" runat="server" />

Get the values of response.

$j.ajax({
    type: 'POST',
    url: '/TestService/TestService.asmx/GetUserDetails',
    data: { userId: UserId},
    dataType: 'text',
    async: false,
    success: function(response) {

                //If response has multiple values then use split function
                v
ar splitData = response.toString().split("$");
                splitUserId = splitData[0];
                //Store values of response in hidden field
                $j('#hfUId').val(splitUserId);
                var data = $j('#hfUId').val();
                SetData(data);
                },
   });

function SetData(data1) {
   document.getElementById('<%=HiddenFieldUId.ClientID%>').value = data1;
}

Now, You can access the value of HiddenFieldUId in server side as HiddenFieldUId.Value