How to show loader widget in ajax call Magento 2?

You can show Magento native loader widget icon on a page for an ajax request.

You can start the loader once the ajax request is started and you can stop loader widget after the response is getting or failed the response.

Its simple to add loader widget icon for an ajax request. Continue reading “How to show loader widget in ajax call Magento 2?”

Ajax response from controller file Magento 2

To Pass ajax response from the controller in Magento 2, You need to use Magento\Framework\Controller\Result\JsonFactory Object.

Magento\Framework\Controller\Result\JsonFactory used for sending a response from a controller to ajax request.

Pass your response in setData() method. Continue reading “Ajax response from controller file Magento 2”

How to pass image data using Ajax to server side in backend magento 2?

By default Image data are not post using ajax. only plain data will be passed as Ajax post. if we need to pass image data using ajax we need to call ajax as below way,
Call jquery using requirejs way in backend template file,
Let’s create a simple example of the form,

We need to Use You FormData() object of Javascript to store our image data and using above way we can just send image data to server side using ajax.