将头信息jQuery.post将头、信息、post、jQuery

由网友(南篱旧事)分享简介:我有以下的code:jQuery.post(encodeURI(ajaxurl + '?action=form_submission'), { 'propertyID[]': propArray, submit: 'Export Gallery', NG_nonce: '...

我有以下的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);
   }
});

这完美的作品,它会创建,然后下载到用户的机器压缩文件夹。我需要做的就是添加标题信息,从而向用户提供的另存为对话框。我已经尝试了几种不同的东西(欲以request.setRequestHeader,其中包括在数据部分头信息),但我有没有运气。是否有人可以给我在这个正确的方向?谢谢。

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.

或者有前

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.

阅读全文

相关推荐

最新文章