【发布时间】:2012-08-23 01:45:45
【问题描述】:
我在运行我的 django 应用程序的同一主机上运行了一个休息服务器(python 瓶)。 从我的 django 应用程序中,我正在使用 ajax 执行获取请求,但即使我可以在我的休息服务器上看到请求的状态成功(返回代码 200,成功),请求也失败了
我的 Ajax 代码:
$.ajax({
url: 'http://hostname:port/ListVms/',
crossDomain: true,
contentType: "application/json",
dataType: 'jsonp',
success: function(data) {
alert('worked');
},
error: function() {
alert("Sorry, error retrieving!");
}
});
Python Rest 方法:
@route('/ListVms/', method='GET')
def get_event():
return json.dumps(JS)
其余服务的输出:
[22/Aug/2012 10:25:45] "GET /ListVms/?callback=jQuery17102901058990901989_1345656355311&_=1345656355356 HTTP/1.1" 200 44
【问题讨论】:
-
服务器返回什么数据?包裹在回调函数中的数据是 jQuery 要求包裹的吗?