HTTP message in iMacros with Javascript for Firefox

I was doing a script automation to retrieve any information from a website, and it is important to send some information using the POST method. Can someone tell me how to use the HTTP Post method with Imacro and javascript for the firefox plugin. The following is the script I found here: Sending an HTTP message using an event triggered by Javascript But this gives me an error when I play the same with the Imacro player.

var url = "http://www.google.com/";
var method = "POST";
var postData = "Some data";
var async = true;

var request = new XMLHttpRequest();
request.onload = function () {
var status = request.status; // HTTP response status, e.g., 200 for "200 OK"
var data = request.responseText; // Returned data, e.g., an HTML document.
}

request.open(method, url, async);

request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
request.send(postData);
+3
source share
2 answers

XMLHttpRequest() no longer supported in firefox 15+

You must define it:

const XMLHttpRequest = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1");
var request = XMLHttpRequest();
+5
source

JavaScript iMacros .

URL GOTO=javascript:window.ScrollTo(0,150);

.

.

URL GOTO=javascript:var url = "http://www.google.com/";var method = "POST";var postData = "Some data";var async = true;var request = new XMLHttpRequest();request.onload = function () var status = request.status; var data = request.responseText; request.open(method, url, async);request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");request.send(postData);
0

All Articles