Path of js file-


code in js file -

define(['jquery', 'mage/validation', 'mage/template'], function ($, _, template) {
    function main(config, element) {
        var $element = $(element);
        var path = config.AjaxUrl;
        $(document).ready(function() {
                var value1  = $('#value1').val();
                var value2      = $('#value2').val();
                var param = 'ajax=1';
                    /*showLoader: true,*/
                    url: path,
                    data: param,
                    type: "GET",
                    dataType: 'json'
                }).done(function (data) {


    return main;

And code in phtml file to ajax call

<script type="text/x-magento-init">
        "#lock": {
                "AjaxUrl":"", "method":"get"

Where settings is controller file Settings.php and doSomeAction() is function which I want to call.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.