weixin_33709590 2017-03-23 18:15 采纳率: 0%
浏览 26

Laravel只刷新查看数据

in my Laravel application I've a simple ajax request which adds a new comment to the database. Now I will reload only the div where the comments listed with the new data. How dose it works?

Thank you for help and sorry for my bad english :)

Request

function comment(user, project, token) {
    $.ajax({
        method: 'POST',
        url: '/comment',
        data: {'project': project, '_token': token, 'author': user, 'content': $('#comment-' + project).val()},
        success: function () {
            console.log('success');
        },
        error: function (jqXHR, textStatus, errorThrown) {
            console.log(JSON.stringify(jqXHR));
            console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
        }
    });
}

Comment section

<div class="panel-google-plus-comment">
                        <img class="img-circle" src="https://mcapi.ca/avatar/{{ Auth::user()->name }}"
                             alt="User Image" height="46" width="46"/>
                        <div class="panel-google-plus-textarea">
                            <textarea rows="4" id="comment-{{$project->id}}"></textarea>
                            <button type="submit" class="[ btn btn-success disabled ]" onclick="comment('{{Auth::user()->id}}', '{{$project->id}}', '{{csrf_token()}}')">Post comment</button>
                            <button type="reset" class="[ btn btn-default ]">Cancel</button>
                        </div>
                        <div class="clearfix"></div>
                    </div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 三菱变频器模块怎么检测触发
    • ¥30 求一下解题思路,完全不懂。
    • ¥30 关于#硬件工程#的问题:求一下解题思路
    • ¥15 运筹学对偶单纯行法构造扩充问题
    • ¥20 XP系统的老电脑一开机就提示找不到rundll.exe,付费求解
    • ¥15 milvus查询出来的score怎么转换成0-1之间的相似性
    • ¥15 lvgl V9移植到linux开发板
    • ¥15 VB.net中在窗体中创建一个button控件来关闭窗体,但是提示错误,我该怎么办
    • ¥15 网上下载好的程序但是arduinoIDE编程报错,运行不了,哪里出错了,能具体给改一下吗
    • ¥15 Sharepoint JS开发 付费技术指导