1

I am trying to update whole minicart content but my ajax call is not working

$.ajax({
    url: "my_controller_url",
    type: "POST",
    success: function (result) {
        $(".minicart").html(result);
    }
});
4
  • If you are getting 404 error than it may be due to routes.xml Mar 1, 2019 at 5:19
  • I am not sure this is 404 or something else. How can I verify?
    – Asim Ali
    Mar 1, 2019 at 5:23
  • check networking console log of browser for get error code.
    – HoangHieu
    Mar 1, 2019 at 5:24
  • ok. let me check
    – Asim Ali
    Mar 1, 2019 at 5:25

1 Answer 1

1

First of all run ajax URL directly to check if your URL is working.

If it is working, then you need to add your ajax in require function and use jQuery instead of $ sign, like this:

require([
    'jquery'
], function($){
    jQuery.ajax({
        url: "my_controller_url",
        type: "POST",
        data: "",
        success: function (res) {
            jQuery(".minicart").html(result);
        }
    });
});
1
  • Thank @Shoaib Munir, let me check this one
    – Asim Ali
    Mar 1, 2019 at 5:24

Your Answer

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

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