.

sending a JSON object on button click event

 

    $("#SaveButton").click(function () {

        //create json 
        var patientId = $('#patientIdHiddenField').val();
        var surname = $('#surnameTextBox').val();
        var forname = $('#fornameTextBox').val();
        var otherNames = $('#otherNamesTextBox').val();
        var postcode = $('#postcodeTextBox').val();
        var telephoneHome = $('#telephoneHomeTextBox').val();
        var telephoneMobile = $('#telephoneMobileTextBox').val();
        var telephoneWork = $('#telephoneWorkTextBox').val();
        var email = $('#emailTextBox').val();
        var nextOfKin = $('#nextOfKinTextBox').val();
        var nextOfKinPhone = $('#nextOfKinPhoneTextBox').val();

        var json = JSON.stringify({
            patientId: patientId,
            surname: surname,
            forname: forname,
            otherNames: otherNames,
            postcode: postcode,
            telephoneHome: telephoneHome,
            telephoneMobile: telephoneMobile,
            telephoneWork: telephoneWork,
            email: email,
            nextOfKin: nextOfKin,
            nextOfKinPhone: nextOfKinPhone
        });

        var uri = '../los/popup/UpdatePatientDetails/';

        $('#dialogBox').empty().dialog('destroy').remove();;

        $.post(uri, json, function () {
            //callback function for success
            $(window.location.reload());
        });

        $(window.location.reload()); 
    });
});

What's your thoughts on this?

*

Protected by WP Anti Spam