I have a django tastypie API and i want to access to the API's resource via a remote host but i cant retrieve data!
I proceed with an ajax call for retrieving data it works great on the local machine but fails when i connect via another machine
$.ajax({
url : 'http://127.0.0.1:8000/api/v1/actors/',
dataType : 'jsonp',
type : 'GET',
data : { format: 'jsonp' },
success : function(data) {
},
error: function(){
}
});
使用CORS允许跨域XMLHttpRequests请求
大家好,我终于解决了我的问题,方法是在API中覆盖我的Resource类,以允许“ Access-Control-Allow-Origin”接受所有来源,并将URL更改为http://192.168.1.XX/api/v1/演员/ !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.