谷歌应用程序引擎+ jQuery的阿贾克斯= 405不允许的方法 [英] Google App Engine + jQuery Ajax = 405 Method Not Allowed

查看:134
本文介绍了谷歌应用程序引擎+ jQuery的阿贾克斯= 405不允许的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人必须能够解释我在做什么错在这里!我试图创建一个AJAX张贴到谷歌应用程序引擎的应用程序最简单的例子......,我没有!

Someone has to be able to explain what I'm doing wrong here! I'm trying to create the MOST simple example of an AJAX post to a Google App Engine app...and I'm failing!

下面是应用蟒蛇


import cgi

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from django.utils import simplejson

class EmailItem(db.Model):
  email = db.StringProperty(multiline=False)
  date = db.DateTimeProperty(auto_now_add=True)

class EmailList(webapp.RequestHandler):
  def get(self):   
    self.response.out.write("You see nothing!")

  def post(self):
    eitem = EmailItem()
    eitem.email = self.request.get("address")
    eitem.put()
    self.response.out.write("success")


application = webapp.WSGIApplication([('/', EmailList)])
def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

和这里的jQuery的

And here's the jQuery


$.ajax({
    	type: "POST",
    	url: "myappengineURL",
    	data: "address=" + sVerifiedEmail,
    	success: function(msg) {
    		alert("Data Saved: " + msg);
    	},
    });

假设我其实知道如何使用jQuery和调用该AJAX调用......为什么我总是收到一个405错误?

Assuming I actually know how to use jQuery and invoke that AJAX call...why do I keep getting a 405 Error?

我重新写这个东西六种不同的方式试图使其工作......我不能!到目前为止,我在看意见的http://博客。 pythoughts.com/posts/AJAX-with-Google-App-Engine#jqueryAjax 和谷歌code的AJAX RPC文章,我不能发布一个链接,因为计算器说NO NO NO。这些都不例子似乎为我工作。

I've re-written this thing six different ways trying to make it work...and I can't! So far I'm looking at advice from http://blog.pythoughts.com/posts/AJAX-with-Google-App-Engine#jqueryAjax and Google code's AJAX RPC article that I can't post a link to because StackOverflow says NO NO NO. Neither of these examples seem to work for me.

我是什么做错了吗?

推荐答案

您的问题被称为同源策略。这就是为什么你看到你的日志OPTIONS方法。您的Ajax请求的域和协议必须是一样的,你是从启动它的人。

Your problem is known as "same origin policy". This is why you see the OPTIONS method in your log. The domain and protocol of your Ajax request must be the same as the one you are launching it from.

<一个href="http://stackoverflow.com/questions/1099787/jquery-ajax-post-sending-options-as-requestmethod-in-firefox">Here's对同一问题有很好的答案。

这篇关于谷歌应用程序引擎+ jQuery的阿贾克斯= 405不允许的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆