Menu Close
    Hire us Request quote Reading list Switch to dark mode
    lockdownWebkulUp

    Return JSON Data with AJAX call in Magento 2

    Today, we will see how to return json data from controller while doing an ajax call.
    Situation may come that you are doing some customization and need to deal will json data from controller then here is the way how we can go for it.

    For that we can use the magento core class,

    which has list of constant mapped to corresponding classes :

    among these, we can use the constant to return json data :

    . . .
    Subscribe Articles

    Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.

    You need to accept conditions to receive letters.
    You've Subscribed!

    Share article via

    . . .

    Now here is the complete code to implement above.

    This is all we need , hope this help you out. happy coding.

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close