0

これが私のコードです:

http://jsfiddle.net/aH2qC/

動作していません。フォームの action="" にあるものを取り、それを $.post URL として使用したいと思います。そして、それを正しくシリアライズしたいので、送信ボタンをクリックして /player/admin ページに到達したかのようにすべてを渡します。

これどうやってするの?

4

3 に答える 3

1

以下を使用します。

    $.post(form.attr('action'),
           form.serialize(),
           function(data) {
               alert("Loaded");
           }
      );

コメント後の更新:

$('.followform').submit(function(e) {
    alert($(this).attr('rel'));
    var form = $(this);

    $.post(form.attr('action'),
        form.serialize(),
        function(data) {
            alert("Loaded");
        }
    );

    e.preventDefault();

    return false;
});

注-フォームセレクターも正しいことを確認してください

/* this */
$('.followform') ... 
/* or */
$('[name="followform"]') ...
/* will do */
于 2012-04-24T17:01:24.437 に答える
0

以下のようなものが必要です。

$(document).ready(function(){
        //v-- Fixed the form selector
    $('.followform').submit(function(e) {
       var form = $(this);
             //   v--- this.action will give you the action URL      
        $.post(this.action, form.serialize(),
           function(data) {
             alert("Loaded");
           });
       return false;
    });
});
于 2012-04-24T17:01:15.913 に答える
0
$(document).ready(function(){
    $('followform').submit(function(e) {
        e.preventDefault();
        var form = $(this),
            action = form.attr('action');;

        $.post(action, form.serialize(),
           function(data) {
             alert("Loaded");
           });
    });
});
于 2012-04-24T17:02:26.263 に答える