You can only use POST via AJAX, so it is necessary that your JS script is running on the same domain as grabhtml.php
If it is, you can simply use jQuery for this, and it will look like:
$.post('grabhtml.php', {
url: document.location,
title: document.title,
html: htmlstuff
}, function(response) {
alert('Successfully posted.');
});
If don't, you could try to embed your script into iframe
(running at the same domain as php script), send title, body, etc. from the parent frame to this iframe
(via window.postMessage
) and issue POST request described above ommitting cross-domain restrictions.
You can read more about window.postMessage here: http://viget.com/extend/using-javascript-postmessage-to-talk-to-iframes
Note: I'm not sure about window.postMessage maximum message size