Magento controller using ajax

Magento controller using ajax. Following is the complete tutorial.

By using ajax with magento controller using ajax you can handle a lot of ajax process like removing product from cart through ajax, customer login via ajax through popup, showing an instant order date anywhere etc. To start with ajax process we need to follow below steps.

magento controller using ajax
magento controller using ajax

Write a jquery ajax call in your template phtml file to invoke the action from controller.

Now write a controller in your magento module i.e, in app/code/local/package/modulename/controller/DataController.php

Before running javascript  test this controller by  hitting url like “ module/data/getdata”. You should get the else part of the code “Nothing is received !”. Then run the js in phtml file and check console.