0

我该如何进行这项工作?我正在尝试做 AJAX 帖子。我习惯做 .serialize 但我想向数组添加另外两个值和键。我怎样才能轻松做到这一点?

        $('#moreprojects').click(function(){
            var skip = $(this).attr('name');
            var more = $(this).attr('rel');
            var param = $('#companies').serializeArray();
            param.push({name: 'skip', value: skip})
            param.push({name: 'more', value: more})
            $.post('projectsmore.php', {param}, function(response){
                $('#projects tbody').append(response);
            })  
        })
4

2 回答 2

1

添加值的方式应该没问题。但你的电话$.post应该是:

$.post('projectsmore.php', param, function(...

{}周围没有param)。

于 2011-08-24T02:05:30.610 回答
0

You're experiencing problems because of the way that you're injecting the param variable into the $.post. Because the variable param is already an object you don't need to wrap it with brackets.

So instead of:

$.post('projectsmore.php', {param},

it should be:

$.post('projectsmore.php', param, 
于 2011-08-24T04:07:46.193 回答