Nov 21, 2009

Using The Post Method Without HTML - Yeah, See the Above Line.

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming

Using The Post Method Without HTML - Yeah, See the Above Line.

szupie
I'm making a Firefox extension, and I need to use the POST method, which apparently is almost exclusively for HTML. Writing Firefox extensions is just like creating a web page, but the only difference is that you should avoid using HTML at all. Javascript, XML, etc. are fine. I've tried using the XMLHttpRequest function with AJAX, but I couldn't get it to work. So does anyone know how to POST information using any language but HTML? (Not GET. But it'd be much easier if I could use GET.)

Comment/Reply (w/o sign-up)

vujsa
Yeah, POST and GET are exclusive to HTML. All other program languages have functions written to be able to use POST and GET.

I think you'll need to use sockets to pass data between the extention and the script. Unfortunately I have no idea of how to help you.

You might try some learn by example and take a peak at a similar extention if that is possible. I'm not a FF user and not interested in writting extentions for it. Just thought I should try to stear you away from the POST method.

Let me know if I'm wrong, I'd love to learn a new method. cool.gif

vujsa

Comment/Reply (w/o sign-up)

mastercomputers
Completely wrong, POST is a method of the HTTP Protocol, which means HTML is not the only language that can do it, but it may seem like the easiest way. So any HTTP capable client should be able to submit POST methods.

Maybe the RFC2616 will help you understand what the requirements are, unless you do want some code shown, any particular language? Remember you must follow the rules of message transmission for it to work as intended.


Cheers,


MC

Comment/Reply (w/o sign-up)

miCRoSCoPiC^eaRthLinG
My question is why couldn't you get AJAX to work ? It's so darned simple. Need any help on that, check out the Shoutbox files - or the content of the Credits Reporter extension I was designing. Nothing better than AJAX to go with FF Extensions.

Comment/Reply (w/o sign-up)

szupie
-----Below was written on 1/25/2005, 07:40 AM EST-----szupie

mastercomputers: I googled the RFC2616 thing. Wow... So much to read... I just wanted to know what languages would make the job the easiest.

miCRoSCoPiC^eaRthLinG: When I try AJAX in my extension, my script would stop in the middle, but it doesn't give any error report. I'm thinking it's something wrong with the send() part of the code. When I try the AJAX code in HTML, I get this error: Error: uncaught exception:
QUOTE
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.setRequestHeader]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: file:///D:/xxxNameRemovedxxx/extensions/astau/chrome/chromeFiles/content/test.htm :: <TOP_LEVEL> :: line 6"  data: no]

I don't know what that means, since Mozilla doesn't have a manual on what error codes mean (or do they?). I'll try looking through your credits extension and the shoutbox code to see what I'm doing wrong.

-----Posts Merged-----szupie
-----Below was written on 1/26/2005, 09:19 PM EST-----szupie

OK, I found out that I had 2 problems in my javascript. The first one was with the send() statement. I did not put quotes around the parameters I wanted to pass (no one told me it needed to have quotes!). The second problem was in a later part of the script, where I tried to write the response to a new page. I was wrong about the AJAX not working, because this part was just plain javascript.

So now, my problem is this: how can I send information to a page with AJAX? I've used this page as a test page for my extension. For the send statement, my code is http_request.send('md5=hello');. Then, when the response comes back, I create a new page and document.write the response to the page. This page's status bar never finishes loading, and the page doesn't seem to have taken any parameters. I've studied the shoutbox code (the credits extension didn't have POST in its code), but I don't see how I've made a mistake. Did anyone spot anything wrong with my code?

 

 

 


Comment/Reply (w/o sign-up)

kalyan
QUOTE(szupie @ Jan 27 2006, 02:19 AM) *

I did not put quotes around the parameters I wanted to pass (no one told me it needed to have quotes!).

Well before doing that just read the docs atleast once.. i hate reading docs but atleast i go through once what are the parameters possible and what it is types....

QUOTE(szupie @ Jan 27 2006, 02:19 AM) *

For that send statement, my code is http_request.send('md5=hello');. Then, when the response comes back, I create a new page and document.write the response to the page. This page's status bar never finishes loading,

Try to use like this
xmlHttpobj.open("POST","yourpage.php?md5=hello");
xml.Httpobj.send("");

check out your server is working properly..

QUOTE(szupie @ Jan 27 2006, 02:19 AM) *

and the page doesn't seem to have taken any parameters. I've made a mistake. Did anyone spot anything wrong with my code?

due to the browser behavious also u get some error (so problem is not from ur side)
Sometimes if u make request to some scripts repeatedly the broswer checks its cache if it available it gives from cache .. it does not go to original server.. So u will get confuse becaz u will the ouput that makes u feel that AJAX is working but u get the same result everytime becaz is it static from cache... u wont get proper response ... well how to solve this...
There is a solution for every problem.....
var myRand = parseInt(Math.Random() * 999999);
xmlhttpobj.open("POST",yourpage.php?md5=Hello&myRand="+myRand);
xmlhttpobj.onreadtstatechange = func.......
xmlhttpobj.send("");
so ur url is not the same at any time becaz a new random is attached so that it does not get one from cache... it feels it is something new and ask the server........

hope u can solve it if u get still problem post the AJAX related problem...

may i know what extension u r writting.......

smile.gif

Comment/Reply (w/o sign-up)

sonoftheclayr
Can't you use POST in XML?
I found something like this on w3schools and when I just went to have a look I got a domain parked message.
Anyway, I would love to give you a link but I'm sure Google, the god of link givers, would be nice enough to help you out.

Comment/Reply (w/o sign-up)

Ola Daniel
QUOTE(szupie @ Jan 25 2006, 12:53 AM) *

I'm making a Firefox extension, and I need to use the POST method, which apparently is almost exclusively for HTML. Writing Firefox extensions is just like creating a web page, but the only difference is that you should avoid using HTML at all. Javascript, XML, etc. are fine. I've tried using the XMLHttpRequest function with AJAX, but I couldn't get it to work. So does anyone know how to POST information using any language but HTML? (Not GET. But it'd be much easier if I could use GET.)


Im not really sure i get what yu want to do... but this might help. I use AJAX to submit my form using the Post method. Heres my code:

CODE

function AJAXInteraction(url, callback) {

    var req = init();
    req.onreadystatechange = processRequest;
        
    function init() {
      if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
      } else if (window.ActiveXObject) {
          return new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
    
    function processRequest () {
      // readyState of 4 signifies request is complete
      if (req.readyState == 4) {
        // status of 200 signifies sucessful HTTP call
        if (req.status == 200) {
          if (callback) callback(req.responseXML);
        }
      }
    }

    this.doGet = function() {
      req.open("GET", url, true);
      req.send(null);
    }
    
    this.doPost = function(str) {
      req.open("POST",url,true);
      req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
      req.send(str);
    }
}


And I use it like this:
CODE

var url = "/MyServlet";
var querystr = "opt=NBCA&optionx=APPROVE&date_created=${param.date_created}";
var ajax = new AJAXInteraction(url, approveResponse);            
ajax.doPost(querystr);



You should be able to adapt this to suit your needs blink.gif

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


See Also,

*SIMILAR VIDEOS*
Searching Video's for post, method, html, yeah, line
advertisement



Using The Post Method Without HTML - Yeah, See the Above Line.

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com