In my header section I have user name and if user have access to different location then he has button saying click me. I want to send ajax call on this button. But JS is not working. Can anybody help me how can I trigger click event on this?
<li class="user-name-welcome">
<span class="user"
data-role="location-section"
tabindex="0"
data-mage-init='{"dropdown":{}}'
data-toggle="dropdown"
data-trigger-keypress-button="true"
data-bind="scope: 'location'">
<span data-bind="text: location().name"></span>
<span data-bind="if: location().multilocation">
(<a href="javascript:void(0)" id="change-location">
click me
</a>)
</span>
</span>
</li>`
Best Answer
Now create "updateLocation" function into respencted js file and from that function you need to call ajax request.