I have some regular anchor tag links on my page that open up a popup window which displays whatever GET data I pass through the url:
<a href="javascript:window.open('view.php?data=a%20bunch%20of%20data');">View</a>
Some of this data is really long, and my crappy web host has a very small limit on the size of the GET data that can be passed in a url. Is there a way to do this with POST data instead, without using html forms?
you could also use an XMLHttpRequest
You would need to use forms. However, you could nest your hyperlink in a form:
<form method="post" action="somepage.php" id="form1">
<input type="hidden" name="field1" value="foo" />
<input type="hidden" name="field2" value="bar" />
<a href="somepage.php?field1=foo&field2=bar" onclick="document.getElementById('form1').submit(); return false;">Hyperlink</a>
</form>
I just ran into the same sort of dilemma and came up with this solution in jQuery:
<a href="#" id="post-link">Example</a>
<script type="text/javascript">
$(document).ready(function () {
$('a#post-link').click(function() {
$('body').append($('<form/>', {
id: 'form',
method: 'POST',
action: '#'
}));
$('#form').append($('<input/>', {
type: 'hidden',
name: 'field1',
value: 'foo'
}));
$('#form').append($('<input/>', {
type: 'hidden',
name: 'field2',
value: 'bar'
}));
$('#form').submit();
return false;
});
} );
</script>
One thing I learned during my long experience with Web development: if you run into limitation from your hosting, host your site somewhere else. Going around hosting limitation - whatever they are - wont't get you very far in the long run. Hosting is cheap, you can get a VPS with generous resources for very reasonable prices nowadays.
It's not worth it.