'How to open a new tab with a post request?

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.



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Robert Lee