如何显示从页面到div的数据

时间:2013-10-06 12:05:31

标签: javascript php jquery html ajax

我有这个将新帖子添加到数据库的ajax代码: -

$(function () {
    $('#upload_file').submit(function (e) {
        var html;
        e.preventDefault();
        $.ajaxFileUpload({
            url: './home/insertPostWall',
            secureuri: false,
            fileElementId: 'inputUpProfile',
            dataType: 'json',
            data: {
                'text': $('#text').val(),
                    'user_id': $('#user_id').val()
            },
            success: function (data) {
                $.each(data.msg, function (index, element) {


                    html = '<li class="right" id="post_row' + element.ev_id + '"><i class="west pointer" title="' + element.ev_id + '"></i><div class="unit"><div class="storyUnit"><div class="imageUnit"><a href="#"><img width="32" height="32" alt="" src="uploads/' + element.pic + '"></a><div id="delpost" style="float:left"><a href="#" id="deletepost" onClick="delete_post(' + element.ev_id + '); return false;" class="south" title="مسح المنشور">X</a></div><div class="imageUnit-content"><h4><a href="./myaccount/profile/' + element.id + '">' + element.fullname + '</a></h4><p>' + element.ev_date + '</p></div></div><p>' + nl2br(element.ev_text) + '</p><br>';
                    if (element.ev_pic) {
                        html += '<p><a href="uploads/' + element.ev_pic + '" class="fancybox" rel="group"><img src="uploads/' + element.ev_pic + '" width="250" height="250" /></a></p>';
                    }
                    html += '</div><ol class="storyActions" id="storyActions' + element.ev_id + '"></ol><div class="storyActions"><form action="" method="post" accept-charset="utf-8"><textarea id="comment' + element.ev_id + '" name="comment' + element.ev_id + '" class="textareacomment" onkeyup="textAreaAdjust(this)" style="overflow:hidden"></textarea><input type="hidden" id="postid' + element.ev_id + '" name="postid' + element.ev_id + '" size="41" value="' + element.ev_id + '" /><button type="button" id="submit" class="uibutton confirmb" onclick="add_comment_wall(' + element.ev_id + ')">ارسل</button></form></div></div></li><div class="clear"></div>';



                    $("#showevent").html(html);
                    $('#text').val('');
                    $('#blah').hide();
                });

            }
        });
        return false;
    });
});

此操作按ajaxFileUpload发送数据并向此div显示数据

$("#showevent").html(html);

错误是当我将第一篇文章插入表格时。帖子没有显示。如果我刷新它显示的页面,之后任何帖子都会显示而不刷新。

我的问题在哪里???

0 个答案:

没有答案