i use jquery in front-end for ajax in phtml page, but i'm getting this error:

Uncaught Error: Mismatched anonymous define() module: function ($, _, template) 

here's my code:

            ], function ($, _, template) {
                var URL = "<?php echo $this->getValidationUrl();?>";
                $(document).on('change','#order_id',function() {
                        if($('#order_id').val() == '') return;
                        var param = 'order_id='+$('#order_id').val();
                            showLoader: true,
                            url: URL,
                            data: param,
                            type: "POST",
                            dataType: 'json'
                        }).done(function (data) {
                            if(data != '1'){
                              $("<p id='error_order' style='color:red;'> "+ data +"</p>").insertAfter( "#order_id" );
                              $('input[type="submit"]').prop('disabled', true);
                              $('input[type="submit"]').prop('disabled', false);

1 Answer 1


If you place your javascript in template file, use require, not define.

Your Answer

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

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