Submit a form using jQuery in PHP

Links for php scripts

Moderators: macek, egami, gesf

phpkiller
New php-forum User
New php-forum User
Posts: 31
Joined: Thu Jun 28, 2012 2:11 pm

Submit a form using jQuery in PHP

Postby phpkiller » Fri Nov 22, 2013 1:28 am

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>

<body align="center">
<div align="center">
<h1>Jquery Form Submit Demo</h1>

<form name="myForm" id="testForm" method="POST" action="send.php">
UserName: <input type="text" name="user" value="test" /> <br/>
Password: <input type="password" name="password" value="test"/> <br/>
</form>

<br/>
<input type="button" id="submit1" value="Submit by Form ID" />
<input type="button" id="submit2" value="Submit by Form Name" />
<input type="button" id="submit3" value="Submit by Form Index" />
<input type="button" id="submit4" value="Submit with Event Handler" />

</div>
</body>
<script>
$(document).ready(function()
{
$("#submit1").click(function()
{
$("#testForm").submit();

});
$("#submit2").click(function()
{
$("form[name='myForm']").submit();
});
$("#submit3").click(function()
{
$("form:first").submit();

});

$("#submit4").click(function()
{
$("#testForm").submit(function()
{
alert('Form is submitting');
return true;
});
$("#testForm").submit(); //invoke form submission

});
});
</script>
</html>

nuWorldVu
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Feb 15, 2014 7:13 am

Re: Submit a form using jQuery in PHP

Postby nuWorldVu » Sat Feb 15, 2014 9:33 am

Hi phpkiller,

You can do this by using the $.post() in jQuery:

var url = 'checkUser.php'

$.post(url, [user=username, pass=password], function(data){

}

This'll send the user ad pass as $_POST[] to the page.

phpkiller
New php-forum User
New php-forum User
Posts: 31
Joined: Thu Jun 28, 2012 2:11 pm

Re: Submit a form using jQuery in PHP

Postby phpkiller » Tue Feb 25, 2014 12:57 am

Appreciate your input...

Thanks,

arunthomas203
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Jun 28, 2014 11:12 pm

Re: Submit a form using jQuery in PHP

Postby arunthomas203 » Sat Jun 28, 2014 11:16 pm

nuWorldVu wrote:Hi phpkiller,

You can do this by using the $.post() in jQuery:

var url = 'checkUser.php'

$.post(url, [user=username, pass=password], function(data){

}

This'll send the user ad pass as $_POST[] to the page.


Thanks :)


Return to “PHP Scripts”

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest