|
|
|
|
![]() ![]() |
Jan 24 2006, 11:53 PM
Post
#1
|
|
|
S.P.A.M.S.W.A.T. Group: Members Posts: 814 Joined: 22-January 05 From: San Antonio, Texas (No, I'm not dumb. I just moved here...) Member No.: 2,284 |
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.)
|
|
|
|
Jan 25 2006, 01:07 AM
Post
#2
|
|
|
Absolute Newbie Group: Admin Posts: 888 Joined: 20-February 05 From: Indianapolis, Indiana, USA (Midwest) Member No.: 2,714 |
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. vujsa |
|
|
|
Jan 25 2006, 03:58 AM
Post
#3
|
|
|
PESTICIDAL MANIAC Group: Members Posts: 626 Joined: 1-September 04 From: Auckland, New Zealand Member No.: 27 |
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 |
|
|
|
Jan 25 2006, 10:54 AM
Post
#4
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 |
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.
|
|
|
|
Jan 27 2006, 02:19 AM
Post
#5
|
|
|
S.P.A.M.S.W.A.T. Group: Members Posts: 814 Joined: 22-January 05 From: San Antonio, Texas (No, I'm not dumb. I just moved here...) Member No.: 2,284 |
-----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? |
|
|
|
May 17 2006, 04:54 AM
Post
#6
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 14 Joined: 16-May 06 Member No.: 13,474 |
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.... 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.. 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....... |
|
|
|
Jun 26 2006, 06:41 AM
Post
#7
|
|
|
Member [ Level 1 ] Group: Members Posts: 44 Joined: 7-May 06 From: Here. Now. It's all that matters. Member No.: 13,259 |
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. |
|
|
|
Jun 29 2006, 05:16 PM
Post
#8
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 15 Joined: 15-June 06 Member No.: 13,954 |
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 |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 11th October 2008 - 02:37 PM |