0

ZetaBoardsフォーラムソフトウェアのフィードバックスクリプトを作成しようとしています。$。post関数を作成しました。送信ボタンをクリックしてフォームを送信しようとすると、「TypeError:e.type is notafunction」のみが返されます。 Firebugで。

これが私のコードです:

<script type="text/javascript">
    var forumID = '1701794';

    if (location.href.indexOf('/profile/') !== -1) {
        $('table.profile:last').after('<form id="feedback_form"><table class="profile" id="feedback"><thead><tr><th colspan="4">Feedback</th></tr></thead><tbody><tr><th colspan="4">Overall Rating: # (Positive: #, Neutral: #, Negative: #)</th></tr><tr><td colspan="4">Submit feedback: <input type="text" name="comment" size="100" /> <input type="radio" name="feed_rate" value="3">0 <input type="radio" name="feed_rate" value="1">1 <input type="radio" name="feed_rate" value="2">2 <button type="button">Submit</button></td></tr><tr><th>Rating</th><th>Comment</th><th>From</th><th>Date</th></tr></tbody></table></form>');

        var profileID = window.location.href.split('profile/')[1].split('/')[0];

        $.get(main_url + 'forum/' + forumID + '/', function (data) {
            $('table.posts:not(#announcement_list) tr[class*="row"]', data).each(function () {
                var userID = $(this).find('td.c_cat-title a').text().split('~')[0];
                var rating = $(this).find('td.c_cat-title a').text().split('~')[1];
                var comment = $(this).find('div.description').text();
                var userHref = $(this).find('td.c_cat-starter a').attr('href');
                var userText = $(this).find('td.c_cat-starter a').text();
                var date = $(this).find('div.t_lastpostdate').text();

                if (profileID === userID) $('#feedback tbody').append('<tr><td>' + rating + '</td><td>' + comment + '</td><td><a href="' + userHref + '">' + userText + '</a></td><td>' + date + '</td></tr>');
            });
        });

        $('#feedback button').click(function () {
            var userID = window.location.href.split('profile/')[1].split('/')[0];
            var description = $('input[name="comment"]').val();
            var rating = $('input[name="feed_rate"]:checked').val();
            var title = userID + '~' + rating;

            $.get(main_url + 'post/?type=1&mode=1&f=' + forumID, function (data) {
                var ast = $('input[name="ast"]', data).val();
                var xc = $('input[name="xc"]', data).val();

                $.post(main_url + 'post/', $.extend({
                    mode: 1,
                    type: 1,
                    ast: ast,
                    f: forumID,
                    xc: xc,
                    sd: 1,
                    title: title,
                    description: description,
                    post: description + '~' + title
                }));
            });
        });
    }
</script>

これが私がそれを使用しているところです:http ://s1.zetaboards.com/Cory/profile/62973/

テストアカウントでログインします。

ユーザー名:テスト

パスワード:Test1

4

1 に答える 1

1

組み込み関数のjQueryを値1で上書きしています。 $。post呼び出し$.typeの目的は何ですか?$.extend({})それがエラーの原因です。

これに置き換えます:

$.post(main_url + 'post/', {
      mode: 1,
      type: 1,
      ast: ast,
      f: forumID,
      xc: xc,
      sd: 1,
      title: title,
      description: description,
      post: description + '~' + title
});

2番目のパラメーターなしで呼び出す$.extend()と、jQueryオブジェクトのデフォルトのプロパティが上書きされます。

于 2012-08-30T06:37:35.123 に答える