nordwest 发表于 2012-2-3 19:46:15

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

本帖最后由 nordwest 于 2012-2-3 19:48 编辑

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

huboo82 发表于 2012-2-3 21:35:31

使用 ajax,服务器成功相应 post 请求以后使用脚本刷新表格。

$.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();

qqzbd 发表于 2012-2-4 10:34:02

这个要怎么做啊
页: [1]
查看完整版本: RESTful 服务问题,请大家给与指导