i want to to a request.JSON on a dynamic form.
is it possible to POST the complete form via a form id ?
<table>
<form id="form">
<tr>
<td>username</td>
<td><input type="text" id="username"></td>
</tr>
<tr>
<td>password</td>
<td><input type="password" id="password"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" id="go" value="go"/></td>
</tr>
</table>
and on the script side:
$('go').addEvent('click',function( event )
{
event.stop();
var myForm = document.id('form');
var request= new Request.JSON (
{
url: 'check_login.php',
method: 'post',
data:
{
form: myForm
},
onSuccess: function( response )
{
if ( response.status )
{
document.location = "home.php"
}
else
{
$('response').addClass('error');
$('response').set('html', response.message);
}
},
});
request.send();
and in the php script i want to check via the $_POST variable.
but i cannot find a method to do it like this. actually im gettinh nothing.
greetz
Sure, look at this link where it shows how to do it:
http://demos111.mootools.net/Ajax.Form
It basically selects the form via your ID, add a listener to submit event and when it comes it sends all the form the way you are looking for 🙂