firefox 확장자에서 웹 서버에 POST 요청을 보내고 싶습니다.firefox 확장자에서 POST 요청 보내기
이 예제에서 POST 요청을 보내고 있습니다. https://developer.mozilla.org/en/Creating_Sandboxed_HTTP_Connections#HTTP_notifications
하지만 제대로 작동하지 않습니다.
나는 현재 이와 같은 코드를 가지고 있습니다.
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = ioService.newURI("http://www.google.com", null, null);
gChannel = ioService.newChannelFromURI(uri);
postData = "a=1&b=2&c=3";
var inputStream = Components.classes["@mozilla.org/io/string-input-stream;1"]
.createInstance(Components.interfaces.nsIStringInputStream);
inputStream.setData(postData, postData.length);
var uploadChannel = gChannel.QueryInterface(Components.interfaces.nsIUploadChannel);
uploadChannel.setUploadStream(inputStream, "application/x-www-form-urlencoded", -1);
uploadChannel.requestMethod = "POST";
uploadChannel.open();
는하지만 난에 대한 오류 어떻게 XMLHttpRequest 객체를 사용하는 방법에 대한
내 코드는 내가 Components.utils.import를 사용하여 수입하고 모듈에하고 액세스 할 수있을 것하지 않습니다 새로운 XMLHttpRequest 객체를 생성합니다. –
@ user329931'Components.classes [ "@ mozilla.org/xmlextras/xmlhttprequest;1"]. createInstance();' – Neil