【发布时间】:2015-10-04 08:04:52
【问题描述】:
我刚开始用cherrypy开发,所以我有点挣扎。 在客户端,我正在选择一些数据,将其转换为 json 并通过 post 方法发送到服务器端。然后我用json做一些操作,最后我想把它发回客户端。所以问题是如何将修改后的 json 返回到客户端(浏览器)。
服务器端:
@cherrypy.expose
def drawChart(self):
__test = cherrypy.request.body.read().strip()
logging.debug(__test)
#...some operations with data
客户端:
function send(JsonArray){
$.ajax({
url: '/drawChart',
type: 'post',
contentType: 'application/json',
dataType: 'json',
success: console.log("Success!"),
data: JsonArray
});
}
【问题讨论】:
标签: python json web-services post cherrypy