Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从Chrome扩展到应用程序引擎的POST请求作为GET请求接收_Javascript_Google App Engine_Post_Google Chrome Extension_Get - Fatal编程技术网

Javascript 从Chrome扩展到应用程序引擎的POST请求作为GET请求接收

Javascript 从Chrome扩展到应用程序引擎的POST请求作为GET请求接收,javascript,google-app-engine,post,google-chrome-extension,get,Javascript,Google App Engine,Post,Google Chrome Extension,Get,我正在尝试从Chrome扩展向使用Google App Engine托管的服务器发送一个最小的POST请求。这是我的服务器代码: class Receive(webapp2.RequestHandler): def get(self): logging.info('received a get') def post(self): logging.info('received a post') 以下是我的Chrome扩展中的Javascript代

我正在尝试从Chrome扩展向使用Google App Engine托管的服务器发送一个最小的POST请求。这是我的服务器代码:

class Receive(webapp2.RequestHandler):
    def get(self):
        logging.info('received a get')

    def post(self):
        logging.info('received a post')
以下是我的Chrome扩展中的Javascript代码:

$.post("http://perativ.com/receive");

$.ajax({
    type: "POST",
    dataType: "JSON",
    url: "http://perativ.com/receive"
});

var xhr = new XMLHttpRequest();
xhr.open("POST", "http://perativ.com/receive");
xhr.send();
我在我的
manifest.json
文件中拥有
权限

我包括了三个相同的请求,以表明什么都不起作用。当我运行这个Chrome扩展,然后检查perativ.com上的服务器日志时,我得到三行代码:“收到一个get”


非常感谢您的帮助,谢谢

通过以下命令可以看到,对您网站的请求正在使用HTTP状态代码301从perativ.com重定向到www.perativ.com。发生此重定向时,POST转换为GET

若要解决此问题,请将请求发送到www.perativ.com而不是perativ.com,或者在您可以到达的范围内禁用重定向

$ curl -X POST http://perativ.com/receive -H 'Content-Length: 0'
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.perativ.com/receive">here</A>.
</BODY></HTML>
$curl-X POSThttp://perativ.com/receive -H'内容长度:0'
301移动
301移动
文档已移动
.

您可以通过以下命令看到,对您网站的请求正在使用HTTP状态代码301从perativ.com重定向到www.perativ.com。发生此重定向时,POST转换为GET

若要解决此问题,请将请求发送到www.perativ.com而不是perativ.com,或者在您可以到达的范围内禁用重定向

$ curl -X POST http://perativ.com/receive -H 'Content-Length: 0'
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.perativ.com/receive">here</A>.
</BODY></HTML>
$curl-X POSThttp://perativ.com/receive -H'内容长度:0'
301移动
301移动
文档已移动
.

您可以通过以下命令看到,对您网站的请求正在使用HTTP状态代码301从perativ.com重定向到www.perativ.com。发生此重定向时,POST转换为GET

若要解决此问题,请将请求发送到www.perativ.com而不是perativ.com,或者在您可以到达的范围内禁用重定向

$ curl -X POST http://perativ.com/receive -H 'Content-Length: 0'
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.perativ.com/receive">here</A>.
</BODY></HTML>
$curl-X POSThttp://perativ.com/receive -H'内容长度:0'
301移动
301移动
文档已移动
.

您可以通过以下命令看到,对您网站的请求正在使用HTTP状态代码301从perativ.com重定向到www.perativ.com。发生此重定向时,POST转换为GET

若要解决此问题,请将请求发送到www.perativ.com而不是perativ.com,或者在您可以到达的范围内禁用重定向

$ curl -X POST http://perativ.com/receive -H 'Content-Length: 0'
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.perativ.com/receive">here</A>.
</BODY></HTML>
$curl-X POSThttp://perativ.com/receive -H'内容长度:0'
301移动
301移动
文档已移动
.

感谢您的回复!不幸的是,我尝试将“perativ.com/receive”的所有实例更改为“www.perativ.com/receive”,但仍然遇到同样的问题。@站点在替换URL后是否重新加载了扩展名?你刚才描述的听起来不可能。啊,不,就是这样!你切换到“www”是完全正确的。我不知道重定向会将帖子转换为GET。非常感谢你!仅供参考如果您想在保留HTTP方法的同时重定向,请使用307或308 HTTP状态码(308和307不受支持)。感谢您的回复!不幸的是,我尝试将“perativ.com/receive”的所有实例更改为“www.perativ.com/receive”,但仍然遇到同样的问题。@站点在替换URL后是否重新加载了扩展名?你刚才描述的听起来不可能。啊,不,就是这样!你切换到“www”是完全正确的。我不知道重定向会将帖子转换为GET。非常感谢你!仅供参考如果您想在保留HTTP方法的同时重定向,请使用307或308 HTTP状态码(308和307不受支持)。感谢您的回复!不幸的是,我尝试将“perativ.com/receive”的所有实例更改为“www.perativ.com/receive”,但仍然遇到同样的问题。@站点在替换URL后是否重新加载了扩展名?你刚才描述的听起来不可能。啊,不,就是这样!你切换到“www”是完全正确的。我不知道重定向会将帖子转换为GET。非常感谢你!仅供参考如果您想在保留HTTP方法的同时重定向,请使用307或308 HTTP状态码(308和307不受支持)。感谢您的回复!不幸的是,我尝试将“perativ.com/receive”的所有实例更改为“www.perativ.com/receive”,但仍然遇到同样的问题。@站点在替换URL后是否重新加载了扩展名?你刚才描述的听起来不可能。啊,不,就是这样!你切换到“www”是完全正确的。我不知道重定向会将帖子转换为GET。非常感谢你!仅供参考,如果您想要在保留HTTP方法的同时重定向,请使用307或308 HTTP状态码(308和307不受支持)。