$(document).on("click", ".edit_location_value", function (e) {
    var edit_id = $(this).data('location-id');
    var edit_country = $(this).data('location-name');
    $('#location_id').val(edit_id);
    $('#name').val(edit_country);

});

$('#edit_location').validate({
    rules: {
        location_name: {
            required: true,
        }
    },
    messages: {
        location_name: {
            required: "Please enter the state.",
        }
    },
    errorClass: 'error-message',
    submitHandler: function (form) {
        var formData = new FormData(form);
        $('#update_passport_btn').text('Please wait...');
            $('#update_passport_btn').attr('disabled', true);
        let base_url = url_path;
        $.ajax({
            url: base_url + '/update_location',
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            success: function(result) {

                if (result.status_code == 200) {
                    toastr.success('Location Updated successfully');
                    setTimeout(function() {
                        window.location.href = base_url + "/manage_location";
                    }, 2000);
                } else {
                    toastr.error('Something Went Wrong');
                    setTimeout(function() {
                        window.location.href = base_url + "/manage_location";
                    }, 2000);
                }
                $('#update_passport_btn').attr('disabled', false);
                $('#update_passport_btn').text('Submit');
            },
        });
        $('#update_passport_btn').attr('disabled', false);
        $('#update_passport_btn').text('Submit');
    }
});