用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2222|回复: 2
收起左侧

[HELP] RESTful 服务问题,请大家给与指导

[复制链接]
发表于 2012-2-3 19:46:15 | 显示全部楼层 |阅读模式
本帖最后由 nordwest 于 2012-2-3 19:48 编辑

大家好,
我使用REST服务,客户端在linux下面, 使用libcurl对数据进行post 操作, 但是post 之后数据要手动刷新才能看到表格里面新的数据,怎么让他自动更新数据显示出来而不需要手动操作呢. 才开始学习CI. 请大家给与指导

发表于 2012-2-3 21:35:31 | 显示全部楼层
使用 ajax,服务器成功相应 post 请求以后使用脚本刷新表格。
JS复制代码
 
$.ajax({
        url: 'your/url',
        type: 'post',
        dataType: 'json',
        success: function(o){
                if(o.result){
                        $('#table').prepend('<tr><td>'+o.data.username+'</td></tr>');
                }
        }
})
 
//或者
new Request.JSON({
        url: 'your/url',
        method: 'post',
        onSuccess: function(o){
                if(o.result){
                        new Element('tr', {'html': '<td>'+o.data.username+'</td>'}).inject($('table'));
                }
        }
}).send();
 
复制代码
发表于 2012-2-4 10:34:02 | 显示全部楼层
这个要怎么做啊

本版积分规则