Hey guys I'm currently using Magento 1.7

I have a custom module that asks for additional information during customer registration. One of the things I ask for is for a specific permit number that is OPTIONAL. Upon loading the customer dashboard (after they register) I want to send an ajax request if they did submit the permit number but not if they didn't include it.

What are some suggestions to how to do this on the dashboard? I don't want to create another custom module and listen for customer registration please respect this decision.

Let me know if anything in unclear and I'll clarify to the best of my ability thanks for taking the time to read my situation.

TLDR: I want to send an Ajax request when the customer registers or logs in and sees their dashboard. I know how to do this by just checking the hello.phtml and adding it at the top but I was wondering other ways of doing so!


Hmm. You've provided a unique set of constraints: you want to submit an AJAX request to some service from the customer dashboard (it's not clear to me if the service is internal or external), and you don't want to add custom code on that backend that will handle this.

It's perfectly safe (from a security standpoint) to send an AJAX request from the customer dashboard, provided that the data being sent is encrypted or not potentially damaging if it is seen by a third source.

To send the request, I'd recommend not editing the hello.phtml file like you talked about, but actually adding a JavaScript file in your theme's local.xml file. That's a lot cleaner. If you're unclear about how to do this, leave a comment and I'll write it up.

Adding a JS file

Here's how to add a JS file to your page in Magento's layout system:

    <your_handle> <!--probably customer_account_index -->
        <reference name="head">
            <action method="addJs">

I recommend putting this in your theme's local.xml file, which will probably be located at app/design/frontend/default/theme424/layout/local.xml. If you're not familiar with how Magento layout works, this is a great intro: http://devdocs.magento.com/guides/m1x/magefordev/mage-for-dev-4.html.

Feel free to ask any questions!

  • Hi tjons! Yes if you could help me write it that would be wonderful. Currently I copied the hello.phtml file from the base and copied it to my app/design/frontend/default/theme424/template/customer/account/dashboard/hello.phtml – CodingMageSheen Nov 10 '16 at 22:52
  • The data is not dangerous and the ajax will be sent to an external source. Adding a JS file for this would be perfect I'll be able to handle it from there if you could help me integrate that. – CodingMageSheen Nov 10 '16 at 22:54
  • Alright. I'm busy right now but I'll take a look at this later tonight. – tjons Nov 10 '16 at 23:14
  • Awesome thanks :) I'll be around I'll submit as your answer whenever you get around to it! – CodingMageSheen Nov 10 '16 at 23:19
  • @CodingMageSheen there you go. This should point you in the right direction now. Let me know if you have any questions! Accepting my answer would be appreciated, thanks! – tjons Nov 11 '16 at 2:05

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.