Renish Khunt
Renish Khunt

Reputation: 5824

JQuery send post request after submit form?

Hello Friends this is my code to form submit and then send post link but form submit success then after not send post link.

document.getElementById("pitch_image_path_form").submit(function(e){

$.post("submit_investorform.php",{'flage':'getallimagesfromselectedid','form':'pitch_image_path_form'},function(result){
                    $("#pitch_image_path_showalldatafromid").html(result);
            });
            e.preventDefault();
    });

this is my code form is submit but post request is not send.

Upvotes: 0

Views: 1555

Answers (6)

user2238699
user2238699

Reputation:

dear renishkhunt please try this code. this is help fully for me.

    $("#pitch_image_path_form").ajaxSubmit({ success: function(){ 
            $.post("submit_investorform.php",{'flage':'getallimagesfromselectedid','form':'pitch_image_path_form'},function(result){
                    $("#pitch_image_path_showalldatafromid").html(result);
                });
     } });

please check this link this is tutorial.

http://malsup.com/jquery/form/

Upvotes: 2

roryok
roryok

Reputation: 9645

.submit() is a jQuery function, so you need to wrap your $("#pitch_image_path_form")[0] in a jQuery wrapper, like so:

$($("#pitch_image_path_form")[0]).submit(function(){

Upvotes: 1

Maen
Maen

Reputation: 10698

When you call .submit(), it posts the form with the specified action of the <form>.

You might want to stop the propagation, by using either event.stopPropagation();, event.preventDefault(); or return false; at the end of your function.

 $("#pitch_image_path_form").submit(function(event){
        event.stopPropagation(); 
        event.preventDefault();

        //Your .post()

        return false;
    });

Plus, as epascarello pointed out, .submit() is a jQuery function.

If you want to use it, use it on the jQuery object by removing [0] before submit(), as you're not supposed to have multiple elements with the same ID.

Upvotes: 0

epascarello
epascarello

Reputation: 207557

Because DOM does not support submit(), there is do submit() function in DOM. Same exact answer when you asked this the last time.

Upvotes: 0

Stanley
Stanley

Reputation: 4035

$("pitch_image_path_form").submit(function(e){
e.preventDefault();
$.post(
    "submit_investorform.php",
    {'flage':'getallimagesfromselectedid','form':'pitch_image_path_form'}
    , function(result) { $("#pitch_image_path_showalldatafromid").html(result); }
);

});

Upvotes: 0

epascarello
epascarello

Reputation: 207557

There is no submit() event in DOM, you are mixing DOM and jQuery

change

document.getElementById("pitch_image_path_form").submit

to

$("#pitch_image_path_form").submit

Upvotes: 0

Related Questions