汽贸公司网站建设,wordpress wood3主题,网站建设ftp软件,南昌seo外包公司小编典典您无法使用Ajax下载文件。因此#xff0c;如果您在ajax上发生了某些情况#xff0c;则应返回url作为响应#xff0c;并像document.location url开始下载过程一样应用它。这里有一个音符。我记得#xff0c;如果不是用户单击启动浏览器#xff0c;浏览…小编典典您无法使用Ajax下载文件。因此如果您在ajax上发生了某些情况则应返回url作为响应并像document.location url开始下载过程一样应用它。这里有一个音符。我记得如果不是用户单击启动浏览器浏览器将阻止文件下载。因此这将正常工作.click(function(){document.location download url})但是如果不是通过用户单击启动它它将被阻止。因此这样的代码.click(function(){$.ajax({...,success:function(download_url_from_server){document.location download_url_from_server;}});})将被浏览器阻止。因此如果您想在发布时传递一些数据可以使用以下方法将表单提交到隐藏的iframe或空白页中function checkToken(token){var $form $(#downloadForm);if ($form.length 0) {$form $().attr({ target: _blank, id: downloadForm, method: POST, action: script.php }).hide();$(body).append($form);}$form.find(input).remove();var args { a: checkToken, b: token }for (var field in args) {$form.append($().attr({value:args[field], name:field}));}$form.submit();}在script.php中如果令牌正常您需要立即从download.php执行代码或者重定向到下载脚本header(Location: download.php?a . $filename)2020-07-26