开发者

how to receive form data submitted with jquery submit()

开发者 https://www.devze.com 2023-02-11 18:49 出处:网络
How can I get the form data if the form is submitted with jQuery submit() function? For example <form action=\"<?=$PHP_SELF;?>\" method=\"post\" id=\"someForm\">

How can I get the form data if the form is submitted with jQuery submit() function? For example

<form action="<?=$PHP_SELF;?>" method="post" id="someForm">
Name: <input type="text" name="name" id="name" /><br />
Email: <input type="text" name="email" id="email" /><br />
</form>

Which I submit with jQuery 开发者_Go百科like:

$("#someForm").submit();

How can I get receive the fields name and email if the form is submitted? Thanks


Just use $('#name').val() and $('#email').val() in the submit callback(

$('#form').submit(function() {
    alert($('#name').val());
});

for example)


You can do it in this way:

  $_POST["name"]

  $_POST["email"]

You can get fields by their names. Hope I made it clear.

0

精彩评论

暂无评论...
验证码 换一张
取 消