Form action submit but NOT redirect (facebook static + magento)

1.1k views Asked by At

This seems simple enough but there are complications...

I have a facebook FBML static page where I want users to sign up to my magento newsletter.

I think I'm right in saying typically you can put the form code as below into the fbml page and on submit it will add the user to the newsletter;

<form action="http://my-site.com/newsletter/subscriber/new/" method="post" id="newsletter-validate-detail"> 
    <fieldset class="block-content"> 
        <legend>Newsletter</legend> 
        <label id="newsletter-label" for="newsletter" class="left">Join our mailing list</label> 
        <div class="input-box left"> 
           <input name="email" type="text" id="newsletter" class="input-text required-entry validate-email" /> 
        </div> 
        <button id="newsletter-submit" type="submit" class="button btn-submit"><span>Join</span></button> 
    </fieldset> 
</form> 

But of course at my site I have an ajax function that returns a thanks for registering, so when this submit is sent from fb, this just lands me at a confirmation message on my domain that is supposed to feed through java and say thanks very much for signing up.

So what I need is some way of posting the action, but keeping the user on facebook, or at least leaving them at some other landing page after the action.

Something that posts but doesn't redirect, or something that posts then redirects to something other than the url in the form action?

Not sure if I need ajax for this or if js is even allowed within the fb environment, could I use any of their proprietary FBML to achieve this?

Many thanks

1

There are 1 answers

1
dm03514 On

Could you add onSubmit="handleData(); return false;" to your form so it doesn't submit? and use the handleData() function to proccess the data in whatever way you need? This will keep the user from moving off the current page.