Reputation: 43833
Using javascript/jquery, I want to open a new tab. I have this code:
window.open("../scripts/map.php", '_blank');
which does it, but I also want to attach a huge json string as a parameter. I don't want to attach it to the url. Is there a way to make a jquery ajax call, and have the returned html string, set in the new tab?
Thanks.
Upvotes: 12
Views: 7841
Reputation: 439
You could define a (possibly hidden) form element, give it the action of the url you want to post to, the method "post", and a target of "_blank", set the json to one of its input fields, the submit the form with jquery using $(form).submit (). You can even use jquery to create and remove the form at runtime.
The target attribute for forms works the same as for hyperlinks.
Upvotes: 15