simpleContact Support Forums » Troubleshooting

jquery/ajax response instead of new page

(5 posts)
  • Started 2 months ago by haymaker
  • Latest reply from haymaker
  1. haymaker
    Member

    What I'm trying to do is include the newsletter signup block to the sidebar of a website. However, any time the user hits the submit button, it goes to a new page. I'd like for it to stay on the same page with the result (either successful submission or email validation).

    I'm a little familiar with jquery (mostly for aesthetic stuff) and not really familiar with ajax at all, but it seems like this could be done fairly easily with a little know-how. I just don't have it.

    Thanks!
    Chris

    Posted 2 months ago #
  2. The client-side jQuery validation and server-side PHP validation should not redirect you to another page unless the form was successfully submitted. There are two things to check:

    1) The links to JavaScript files in the head of your pages need to be correct, or the form will post and only the server-side validation will be executed.

    2) The form needs to post to the page that it is on. Make sure that the action attribute on the form tag is correct for each page that the form is on.

    Posted 2 months ago #
  3. haymaker
    Member

    Hey, thanks for the reply. I wasn't posting to the page that it was on so that definitely helps. But is there a way to get the "contact_thankyou" page to load inside a specified div, for instance? Or to return some value so I can show a message on the same page instead of redirecting?

    Thanks again for the response - this is really such a cool tool.

    Posted 2 months ago #
  4. No problem :)

    It would take significant reprogramming of the way the form processor works to make it update the page using AJAX. I prefer to redirect to a "thank you" page because that makes it easy to track form submissions (e.g. mailing list subscribes) as goal conversions in Google Analytics.

    You could get the effect you want by using an iFrame. The "thank you" message would load inside the frame instead of taking the browser to another URL.

    Posted 2 months ago #
  5. haymaker
    Member

    Thanks for your help Alex - good point about the analytics. I was thinking about the iframe thing, but thought if there was a simple AJAX solution, I'd go with that. Thanks again for your help!

    Posted 2 months ago #

RSS feed for this topic

Reply

You must log in to post.