I have the following code:
jQuery.post(encodeURI(ajaxurl + '?action=form_submission'),
{ 'propertyID[]': propArray, submit: 'Export Gallery', NG_nonce: '<?php print $this->nonce; ?>' },
function (result) {
var obj = jQuery.parseJSON(result);
if (typeof(obj['error']) == 'undefined') {
if (typeof(obj['url']) != 'undefined') {
window.location.href = obj['url'];
var confirmBox = confirm('The gallery has been exported.');
} else {
alert('Error');
}
} else {
alert(obj['error']);
}
if (redirect == 1) {
window.location.href = '/wp-admin/media-upload.php?post_id='+propertyID+'&type=image&tab=<?php print $_REQUEST['tab']; ?>';
} else {
jQuery(element).html(oldHtml);
}
});
This works perfectly, it creates a zipped folder that is then downloaded to the users machine. What I need to do is add header information so the user is given the ‘save as’ dialog box. I have tried several different things (trying to use request.setRequestHeader, including header information in the data portion) but I am having no luck. Can someone please send me in the correct direction on this? Thanks.
Or is there a way to add the header information right before
window.location.href = obj['url']
I need to figure this out, Thanks again for any help.
This “save as” dialog is up to the browser. Different browsers will handle file downloads differently.