[英]Sending POST request in firefox addon (javascript)
我使用firefox插件(javascript)嘗試將POST請求發送到服務器以獲取會話ID,但是似乎所有常規方法都不起作用,我已經嘗試過xmlhttprequest,並且無法通過表單獲取它,因為內部代碼。 是否有辦法使此工作正常進行,甚至使用插件SDK也可以嗎?
我的嘗試參考:
使用新的Addon SDK,您應該使用新的Request API而不是XMLHttpRequest。 新界面也更易於使用。
這是一個簡單的示例:
// make sure this gets executed BEFORE making the Request
var Request = require("sdk/request").Request;
Request({
url: "http://example.com/hello-world.php",
content: { hello: 'world' },
onComplete: function (response) {
console.log( response.text );
}
}).post();
我建議您可以看看此MDN教程: 入門
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.