trying to send data to a new window that doesn't originate from a form.
This is what I tried:
window.open('/path/to/file.php', 'bundle', 'height=700, width=500');
$.post('/path/to/file.php', {id: $(this).data('id')}, function(res)
{});
but var_dumping $_POST returns an empty array.
the data as you can see is being passed with $(this) (the trigger is an .on('click')) and I'm not a fan of the idea of having to create a hidden form - surely there must be a way to use $.post (or something else) to just post and open a new window - any ideas? Thanks :)
Found an answer:
$.post('path/to/post.php', {data: 4}, function(res)
{
var win = window.open('', 'UNIQUE_WINDOW1', 'width=1472, height=300');
with(win.document)
{
open();
write(res);
close();
}
});
this posts the data to post.php, opens the page using with
and then writes the response to the window. No performance penalties either it seems. (note - refreshing these pages won't update, you need to trigger the $.post event to update the page)
I think you can try something like this
window.open('/path/to/file.php?data1=variable&data2=varaible2', 'bundle', 'height=700, width=500');