rodolfo navalon
rodolfo navalon

Reputation: 193

using the form action in jquery to go to php

How can I use the action in html form so I can send all the data form my form

I tried $("#formupload").attr('action') seems not working

Here is my code:

$(".clickupload").click(function () {
        $("#dialog-form").dialog("open");
    });
    $("#dialog-form").dialog({
        autoOpen: false,
        closeOnEscape: true,
        title: "Upload Picture",
        width: 400,
        height: 300,
        modal: true,
        buttons: {
            Cancel: function () {
                $(this).dialog("close");
            },
            Upload: function () {
                $(document).ready(function () {

                    $("#formupload").attr('action');
                });

    }

        }
    });



<div id="dialog-form">
<form id="formupload" action="ProfileImages/FileUpload.php" method="POST" enctype="multipart/form-data">
<input  type="file" name="uploadProfilePicture"/>
</form>
</div>

Upvotes: 0

Views: 67

Answers (3)

Virus721
Virus721

Reputation: 8335

What bweobi said, and eventually put all the jQuery initialisation stuff on document ready to make sure the document is all initialised before you add event handlers to its elements :

(function($) { // Allows you to create variables locally so
               // there are no conflict with other stuffs.

    $(document).ready(function() {

        // You can name jQuery variables with a dollar so you can easily make
        // the difference betwen jQuery and non-jquery objects.
        $dialogForm = $('#dialog-form'); // Half queries, double speed.

        $(".clickupload").click(function () {
            $dialogForm.dialog("open");
        });

        $dialogForm..dialog({
            autoOpen:      false,
            closeOnEscape: true,
            title:         "Upload Picture",
            width:         400,
            height:        300,
            modal:         true,
            buttons: {
                Cancel: function () {
                    $(this).dialog("close");
                },
                Upload: function () {
                    $("#formupload").submit();
                }
            }
        });

    });

})(jQuery); // Alows you not to use $ in global scope in case
            // you use multiple libraries that use the $.

Upvotes: 0

Nick
Nick

Reputation: 4212

Try simply $("#formupload").submit()

Upvotes: 0

bwoebi
bwoebi

Reputation: 23787

You mean eventually $("#formupload").sumbit();? What you're doing is reading the attribute and then doing nothing with it?

Upvotes: 1

Related Questions