Magento – Mini cart not update the data after execute custom action

magento-2.1.10magento2

I have create a custom module and perform the action using ajax call. I have created the sections.xml and update the below code.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="southlincprotection/Index/Index">
        <section name="cart"/>
    </action>
</config>

but it is not working and not updating the minicart item after succesfull ajax execution. can anyone please let me where I am doing mistakes.

Package Name >> Southlinc

Module Name >> Protection

Controller >> Index >> Index.php

I have defined the frontname "southlincprotection" in routes.xml

my Ajax code is below

var param = 'quoteid=<?php echo $quoteId; ?>&ajax=1';
    $.ajax({
        showLoader: true,
        url: '<?php echo $baseUrl; ?>southlincprotection',
        data: param,
        type: "POST",
        dataType: 'json'
    });

Best Answer

The ajax mini cart updated code below work for, you can try this.

    $.ajax({
                    url: "/southlincprotection/Index/Index",
                    data: {
                        item_id: this.id,
                    },
                    showLoader: true,
                    type: 'POST',
                    dataType: 'json',
                    success: function (response) {
                        console.log("Message : "+response.success);
                        require([
                           'Magento_Customer/js/customer-data',
                           'Magento_Checkout/js/model/quote',
                           'ko',
                           'uiComponent',
                           'jquery',
                           'Magento_Checkout/js/model/cart/totals-processor/default',
                           'Magento_Checkout/js/model/cart/cache'
                        ], function (customerData, quote, ko, Component,$, defaultTotal, cartCache) {
                            'use strict';
                            var sections = ['cart'];
                            customerData.invalidate(sections);
                            customerData.reload(sections, true);
                            defaultTotal.estimateTotals();
                            cartCache.set('totals',null);
                        });
                    }
                });