Is it possible to send data to the server using POST?
Ie) I want to send POST data to url:
http://www.a.com/b?cmd=tt
With POST data:
a=1
b=2
Is it doable and how?
In fact, you can now (since Firefox 3.5) make pure XHR POST from Firebug, to any domain, you just like in pure JavaScript on the page, with the subject of the same restrictions.
The code is a bit lengthy and not handy at all though if you want to use it frequently (unless you store it and copy-paste each time)
Paste into console (it would open Command Editor automatically, as it's > 1 line)
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://test/xhrtest.php?w=www");
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send("a=aaa&b=bbb");
Remember that on server-side, you must enable CORS, to see the response in Firebug (otherwise, the request will be sent, but you won't see the response in Firebug; you could see it in Fiddler though); if you opened Firebug while you're on page http://foo/somepage
, then that URL will be sent by XHR in the HTTP referrer header field, and that domain must be allowed to receive XHR responses via Access-Control-Allow-Origin
header which you can either set in the server config, or directly in the page.
Example in PHP:
<?php
header('Access-Control-Allow-Origin: *');
//you can adjust it more fine-grained, perhaps in an 'if'
//header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
//header('Access-Control-Allow-Origin: http://foo');
echo $_POST['a'] . "\r\n";
echo $_POST['b'] . "\r\n";
echo $_GET['w'] . "\r\n";
?>
Then you can use Firebug's Net
tab to inspect the response (and also in the Console
tab if you have Console > RIGHT CLICK > Show XMLHttpRequest
option enabled).
Quote from Mike Cooper on a similar question:
As far as I know, Firebug can't do this. However, there is a very useful Firefox extension, in the spirit of Firebug, called Tamper Data. This should be able to do what you want.
It allows you to monitor each request made by the browser, and you can turn on an option that allows you to look at, and edit, every single request before it gets sent.
See other answers at source:
How do I POST to a web page using Firebug?
Also see: Using Firebug to send form data
The above work if you simply want to modify HTTP requests, but to actually create HTTP requests, there is a Firefox extension called Poster, which has the following description:
A developer tool for interacting with web services and other web resources that lets you make HTTP requests, set the entity body, and content type. This allows you to interact with web services and inspect the results...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With