window.open() rather than ajax url
window.open() rather than ajax url
I am trying to get the result of submit() from an editor call to cause a window.open() to get the result of the GET call to an URL.
Here is what I have that does the GET request, but of course datatables is waiting for the json response which won't happen.
In fact what will happen is that the URL I want to GET towards will create a PDF and send that to the new window.
var labeleditor = new $.fn.dataTable.Editor( {
"ajax": {
"url": "pdf/label.php",
"type": "GET",
},
"formOptions": {
main: {
blurOnBackground: false
}
},
"fields": [
{
"name": "printrun",
"label": "Enter the Number of Labels to Print"
}
],
i18n: {
create: { title: "Print Blank Valve Labels" }
}
});
So my PHP script at pdf/label.php can receive the $_GET string no problem and decodes the value supplied for "printrun", and even generates the PDF file as required.
But I want a new browser window - I assume via window.open(), to capture the generated PDF result, not ajax like a normal DT operation.
thanks.
This question has an accepted answers - jump to answer
Answers
Hi,
Interesting one. I think what you'll probably need to do is have
pdf/label.php
return some information to the Editor request that will cause the page to be forwarded on. So rather than immediately generating and returning the PDF, it would give, for example an id, or a url then you could just do:Allan
Thanks for the huge clue on how to do it. It works great.
Here are some code snippets for those who come later looking for crumbs.
and the PHP to do the linkage (latest DT format)
Lots of other ways to do it, I chose GET as that was easier to debug.