Jquery and forms

Posted on 2011-10-12
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
    LVL 81

    Accepted Solution

    $(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

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

    Author Closing Comment

    My bad... made a glaring error! Many thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

    This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now