mootools表单json post请求


mootools form json post request

我想要一个动态表单上的request.JSON

是否可以通过表单id将完整的表单POST?

<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>

在脚本方面:

$('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();

在php脚本中,我想通过$_POST变量进行检查。但我找不到这样做的方法。实际上我什么都没得到。

greetz

当然,看看这个链接,它展示了如何做到这一点:

http://demos111.mootools.net/Ajax.Form

它基本上是通过您的ID选择表单,添加一个监听器来提交事件,当它出现时,它会按照您想要的方式发送所有表单:-)