Jquery and forms

Posted on 2011-10-12
Medium Priority
Last Modified: 2012-05-12
Hi Experts,

I have this script that sends a form...

    $(document).ready(function (){
         $('form[name=admin]').submit(function (){
                $.get("/actions/add/blog.php", $('form[name=admin]').serialize(), function(data){$('#form-message').html(data);});
                return false;

What i really would like is to use this script (which works perfectly) but for it to follow the actual forms action url...

Can this be done? with variables? Get action attr? Its because there are multiple forms across my site...
Many Thanks in Advance
Question by:maccaj51
  • 2
LVL 83

Accepted Solution

leakim971 earned 2000 total points
ID: 36955368
$(document).ready(function (){
         $('form[name=admin]').submit(function (){
                $.get( $(this).attr("action"), $('form[name=admin]').serialize(), function(data){$('#form-message').html(data);});
                return false;

Author Comment

ID: 36955414
this seems to load the current url into #form-message on submit...?

Author Closing Comment

ID: 36955422
My bad... made a glaring error! Many thanks!

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question