views:

108

answers:

1

I'm trying to send POST data to the current tab, based on this (https://developer.mozilla.org/en/Code_snippets/Post_data_to_window).

But it doesn't seem to be working, nothing happens... I'd be very grateful to whoever shines light on the problem! Thanks in advance! :D

  var dataString = "name1=data1&name2=data2";

  var stringStream = Cc["@mozilla.org/io/string-input-stream;1"].
  createInstance(Ci.nsIStringInputStream);
  if ("data" in stringStream) // Gecko 1.9 or newer
  stringStream.data = dataString;
  else // 1.8 or older
  stringStream.setData(dataString, dataString.length);

  var postData = Cc["@mozilla.org/network/mime-input-stream;1"].
  createInstance(Ci.nsIMIMEInputStream);
  postData.addHeader("Content-Type", "application/x-www-form-urlencoded");
  postData.addContentLength = true;
  postData.setData(stringStream);

  loadURI("http://www.mysite.com/login.php", "http://www.mysite.com/", postData);
+1  A: 

I should probably post that I found the answer. The referer must be null, and if you need to use one, I can dig up the link where it talks about how one is created. Just posting that...

motionman95