Я разрабатываю подключаемый модуль jQuery, который будет соединителем для некоторого REST API. Реализация проста, но та же политика происхождения определенно болезненна. I need to perform mostly POST requests.
I also tried to implement the OPTIONS method and returning (is python, but the meaning should be clear)
def options(self):
self.response.headers['Access-Control-Allow-Origin'] = self.request.host_url
self.response.headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'
self.response.headers['Access-Control-Allow-Headers'] = 'x-requested-with'
self.response.headers['Access-Control-Max-Age'] = '1728000'
still doesn't work... any idea ?
PS: I have seen that there are other question with a similar topic but i need a specific solution for POST method (GET could be easely implemented by using iframes)
Javascript example:
$.ajax({
url: options.protocol+'://'+options.host+':'+options.port+'/'+method,
data: rawData,
async:false,
dataType: "json",
type:"POST",
success:function(data)
{
alert('asd');
result.data = data;
alert(data);
},
error:function(lol){
alert('omggg !!!!'+lol);
}
});
EDIT: added javascript code example