Tag: webapp2

CORS – 使用AJAX在Python(webapp2)Web服务上发布

这将是漫长的: 好的,我正在开发一个谷歌日历小工具,它将请求发送到托管在Google App Engine上的Python webapp2 REST api。 当我尝试发布因CORS而不允许我发布的内容时,问题就来了。 在Chromes的DevTools中它说: Method: OPTIONS. Status: (failed) Request header field Content-Type is not allowed by Access-Control-Allow-Headers. Origin https://hq34i4geprnp5vci191ljfuhcoerscl4-a-calendar-opensocial.googleusercontent.com is not allowed by Access-Control-Allow-Origin. 我知道这是因为CORS。 这里: Ajax – Access-Control-Allow-Origin不允许使用Origin localhost 它说我必须添加 Access-Control-Allow-Origin: * 对于标题,但是我又是ajax的新手,我想知道它是否以这种方式完成: $.ajax({ type: “POST”, url: “https://myapp.appspot.com/service”, contentType: “application/json; charset=utf-8”, data: data, beforeSend: function (request) { request.setRequestHeader(“Access-Control-Allow-Origin”, “*”); […]