在Firefox扩展的JavaScript中的HTTP POST [英] HTTP POST in javascript in Firefox Extension
本文介绍了在Firefox扩展的JavaScript中的HTTP POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这不是通过参数传递的:
var params =a = 1& b = 2& c = 3
req.open('POST',' http://www.mywebsite.com/');
req.send(params);
关于我在做什么的错误?谢谢。
解决方案
确保你已经包含了头文件来告诉服务器你发送的是什么类型的请求体:
req.setRequestHeader('Content-Type','application / x-www-form-urlencoded');
(假设 req
是 XMLHttpRequest
在代码中创建。)
I'm a newbie trying to do a simple HTTP post in JS within a Firefox extension..
This isn't passing through the parameters:
var params = "a=1&b=2&c=3"
req.open('POST', 'http://www.mywebsite.com/');
req.send(params);
Any ideas on what I'm doing wrong? Thanks.
解决方案
Make sure you've included the header to tell the server what type of request body you're sending it:
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
(Assuming req
is an XMLHttpRequest
created earlier in the code.)
这篇关于在Firefox扩展的JavaScript中的HTTP POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文