This is my script from my phtml file:

<script type="text/x-magento-init">
        "*": {
            "Vendor_Namespace/js/custom": {
                "ajaxShipmentUrl": "<?php echo $block->getUrl('vendor_namespace/ajax/scanShipment'); ?>"

I want to get the value of my ajaxShipmentUrl paramater in the custom js file. This is the content of the custom js file:

define([ 'jquery', 'jquery/ui'],
    function ($) {
        'use strict';
        $.widget('mage.fulfillment', {
            options: {
                // Define variables
            _init: function (config) {
                // ... the rest of the script
     // ... the rest of the script

     return $.mage.fulfillment;

Is there a way to get the ajaxShipmentUrl in my _init method ?

Thank you

1 Answer 1


You can get the values passed from phtml to widget in any function using below code,


  • Woaw, so fast, thnx , it works. I learnt smth today :) Feb 24, 2020 at 12:27
  • Cheers bro ....
    – aravind
    Feb 24, 2020 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.