前端导出功能get和post两种方式

get方式:

  var url = ’/sjdd/eventQuery/exportSuperviseEventExcel.do?beginDate=' + beginDate + '&endDate=' + endDate ;

  window.location.href = url;

post方式: 

  var _url = ’/sjdd/eventQuery/exportSuperviseEventExcel.do‘,
     _data = {
        beginDate: beginDate,
      endDate: endDate,
      type: 'excel';
    }
  var form = $('<form method="post" action="' + _url + '"></form>');
  $.each(_data, function(k, v) {
    form.append($('<input type="hidden" name="' + k+ '" value="' + v + '">'));

  });
  $('body').append(form);
  form.submit(); // 自动提交

  form.remove();

    

上一篇:锋利的jQuery之事件


下一篇:算法题丨Longest Consecutive Sequence