如何在form表单提交中添加我需要的请求头?

哈一下 发布于 2016/10/18 19:18
阅读 10K+
收藏 0
<!DOCTYPE html>
<html lang="en">
<head>
<!-- BEGIN META --> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Olive Enterprise">
<!-- END META -->


<!-- BEGIN SHORTCUT ICON -->
<link rel="shortcut icon" href="img/favicon.ico">
<!-- END SHORTCUT ICON -->
<title>蓝石资管后台系统</title>
 
<!-- BEGIN STYLESHEET -->  
<link href="css/bootstrap.min.css" rel="stylesheet"><!-- BOOTSTRAP CSS -->
<link href="css/bootstrap-reset.css" rel="stylesheet"><!-- BOOTSTRAP CSS -->
<link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet"><!-- FONT AWESOME ICON STYLESHEET -->
<link href="assets/dropzone/css/dropzone.css" rel="stylesheet"><!-- DROPZONE CSS  -->
<link href="css/style.css" rel="stylesheet"><!-- THEME BASIC CSS -->
<link href="css/style-responsive.css" rel="stylesheet"><!-- THEME BASIC RESPONSIVE  CSS -->

<!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
<!-- END STYLESHEET --> 
</head>
<body>

<!-- BEGIN SECTION --> 
<section id="container" class="">
 
<!-- BEGIN HEADER -->
      <header class="header white-bg">
        <!-- SIDEBAR TOGGLE BUTTON -->
			<div class="sidebar-toggle-box">
			  <div  data-placement="right" class="fa fa-bars tooltips">
			  </div>
			</div>
        <!-- SIDEBAR TOGGLE BUTTON  END-->
        <a href="index.html" class="logo">
          蓝石资管
          <span>
            后台管理系统
          </span>
        </a>
          
        
		 <!-- START USER LOGIN DROPDOWN  -->
		
        <div class="top-nav ">
          <ul class="nav pull-right top-menu">
            <li>
              <input type="text" class="form-control search" placeholder="搜索">
            </li>
            <li class="dropdown">
              <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                <img alt="" src="img/avatar1_small.jpg">
                <span class="username">
                  	汪柳辉
                </span>
                <b class="caret">
                </b>
              </a>
              <ul class="dropdown-menu extended logout">
                <li class="log-arrow-up">
                </li>
              
                <li>
                  <a href="#">
                    <i class="fa fa-cog">
                    </i>
                		    个人中心
                  </a>
                </li>
                <li>
                  <a href="#">
                    <i class="fa fa-bell-o">
                    </i>
                 		   我的消息
                  </a>
                </li>
                <li>
                  <a href="login.html">
                    <i class="fa fa-key">
                    </i>
                 		   注销
                  </a>
                </li>
              </ul>
            </li>
          </ul>
        </div>
		<!-- END USER LOGIN DROPDOWN  -->
      </header>
      <!-- END HEADER -->

<!-- BEGIN SIDEBAR -->
      <aside>
        <div id="sidebar" class="nav-collapse">
          <ul class="sidebar-menu" id="nav-accordion">
            <li >
              <a href="index.html" class="active">
                <i class="fa fa-dashboard">
                </i>
                <span>
               		   蓝石资管
                </span>
              </a>
            </li>
            <li class="sub-menu">
              <a href="javascript:;">
                <i class="fa fa-list-ul">
                </i>
                <span>
              		    任务审核
                </span>
                <span class="label label-success span-sidebar">
                  6
                </span>
              </a>
			  
			  <ul class="sub">
                <li>
                  <a href="#">
              		      审核名片
                  </a>
                </li>
                <li>
                  <a href="#">
                		    审核文章
                  </a>
                </li>
                <li>
                  <a href="#">
                		    审核观点
                  </a>
                </li>
                <li>
                  <a href="#">
                		    审核活动
                  </a>
                </li>
                <li>
                  <a href="#">
               		     审核培训
                  </a>
                </li>
                <li>
                  <a href="#">
                    	审核聚会
                  </a>
                </li>
			 </ul>
            </li>
			
            <li class="sub-menu">
              <a href="dropzone.html">
                <i class="fa fa-cloud-upload">
                </i>
                <span>
             		     一级行情源
                </span>
                <span class="label label-info span-sidebar">
                  1
                </span>
              </a>
			 
            </li>
			
            <li class="sub-menu">
              <a href="javascript:;">
                <i class="fa fa-edit">
                </i>
                <span>
             		     内容发布
                </span>
                <span class="label label-primary span-sidebar">
                  5
                </span>
              </a>
			  
              <ul class="sub">
                <li>
                  <a href="#">
                 	   发布聚会
                  </a>
                </li>
                <li>
                  <a href="#">
                 	   发布活动
                  </a>
                </li>
				<li>
                  <a href="#">
                   	 发布话题
                  </a>
                </li>
				<li>
                  <a href="#">
                  	  发布职位
                  </a>
                </li>
				<li>
                  <a href="#">
                    	发布培训
                  </a>
                </li>
              </ul>
			  
            </li>
			
            <li class="sub-menu">
              <a href="javascript:;">
                <i class="fa fa-cogs">
                </i>
                <span>
                  App内容配置
                </span>
                <span class="label label-info span-sidebar">
                 Building
                </span>
              </a>

            </li>
            <li class="sub-menu">
              <a href="javascript:;">
                <i class="fa fa-user">
                </i>
                <span>
                 	 用户管理
                </span>
                <span class="label label-inverse span-sidebar">
                  Building
                </span>
              </a>
			  
            </li>
          </ul>
        </div>
      </aside>
      <!-- END SIDEBAR --> 

 <!-- BEGIN MAIN CONTENT --> 
<section id="main-content">
    <section class="wrapper site-min-height">
        <div class="col-lg-6">
          <section class="panel">
            <header class="panel-heading">
                 <span class="label label-primary">导入Wind数据</span>
          
            </header>
            <div class="panel-body">
                <form action="post" id="wind" name="windupload" class="dropzone" method="post" enctype="multipart/form-data" onsubmit="windupload()">
                	<input type="hidden" name="file"/>
                	<input type="hidden" name="wind"/>
                </form>
            </div>
          </section>
        </div>
		
		<div class="col-lg-6">
          <section class="panel">
            <header class="panel-heading">
                 <span class="label label-primary">导入QB数据</span>
          
            </header>
            <div class="panel-body">
                <form action="submit" id="qb" class="dropzone" name="qbupload" enctype="multipart/form-data" onsubmit="qbupload()" method="post">
                	 <input type="hidden" name="file"/>
                	 <input type="hidden" name="qb"/>
                </form>
            </div>
            </section>
		</div>	
		
		<div class="col-sm-6">
                     <section class="panel">
                        <header class="panel-heading no-border">
                           <span class="label label-primary">Wind上传记录表</span>
                           <span class="tools pull-right">
                          
                           
                           </span>
                        </header>
                        <table class="table table-bordered">
                           <thead>
                              <tr>
                                 <th>#</th>
                                 <th>上传的文件名</th>
                                 <th>上传的时间</th>
                                 <th>上传的大小</th>
                              </tr>
                           </thead>
                           <tbody>
                              <tr>
                                 <td rowspan="2">1</td>
                                 <td>Parth</td>
                                 <td>Jani</td>
                                 <td>@parth</td>
                              </tr>
                             
                           </tbody>
                        </table>
                     </section>
                  </div>
		
		<div class="col-sm-6">
                     <section class="panel">
                        <header class="panel-heading no-border">
                           <span class="label label-primary">QB上传记录表</span>
                           <span class="tools pull-right">
                          
                           </span>
                        </header>
                        <table class="table table-bordered">
                           <thead>
                              <tr>
                                 <th>#</th>
                                 <th>上传的文件名</th>
                                 <th>上传的时间</th>
                                 <th>上传的大小</th>
                              </tr>
                           </thead>
                           <tbody>
                              <tr>
                                 <td rowspan="2">1</td>
                                 <td>Parth</td>
                                 <td>Jani</td>
                                 <td>@parth</td>
                              </tr>
                             
                           </tbody>
                        </table>
                     </section>
                  </div>
    </section>
</section>
 <!-- END MAIN CONTENT --> 
 
 
 <!-- BEGIN FOOTER -->
      <footer class="site-footer">
        <div class="text-center">
          2016 &copy; 蓝石资管 by 
          <a href="" target="_blank">
            FiccLink
          </a>
          
        </div>
      </footer>
      <!-- END  FOOTER -->
 
</section>
<!-- END SECTION -->  

<!-- BEGIN JS --> 
    <script src="js/jquery.js" ></script><!-- BASIC JS LIABRARY -->
    <script src="js/bootstrap.min.js" ></script><!-- BOOTSTRAP JS  -->
    <script src="js/jquery.dcjqaccordion.2.7.js"></script><!-- ACCORDING JS -->
    <script src="js/jquery.scrollTo.min.js" ></script><!-- SCROLLTO JS  -->
    <script src="js/jquery.nicescroll.js" > </script><!-- NICESCROLL JS  -->
	<script src="assets/dropzone/dropzone.js" ></script><!-- DROPZONE JS  -->
	<script src="assets/dropzone/form-dropzone.js" ></script><!-- DROPZONE JS  -->
	<script src="js/respond.min.js" ></script><!-- RESPOND JS  -->
	<script src="js/common-scripts.js" ></script><!-- BASIC COMMON JS  -->

<!-- END JS --> 

<script>
/*--------- create remove function in dropzone --------*/

 Dropzone.options.myDropzone = {
		
	
                init: function() {
                    this.on("addedfile", function(file) {
                        // Create the remove button
                        var removeButton = Dropzone.createElement("<button class='btn btn-primary btn-sm btn-block'>移除文件</button>");
                        
                        // Capture the Dropzone instance as closure.
                        var _this = this;

                        // Listen to the click event
                        removeButton.addEventListener("click", function(e) {
                          // Make sure the button click doesn't submit the form:
                          e.preventDefault();
                          e.stopPropagation();

                          // Remove the file preview.
                          _this.removeFile(file);
                          // If you want to the delete the file on the server as well,
                          // you can do the AJAX request here.
                        });

                        // Add the button to the file preview element.
                        file.previewElement.appendChild(removeButton);
                    });
                }            
            };
function windupload(){
	var AjaxURL= "http://localhost:8080/aster/manager/newBonds/updateExcel"; 
	alert($('#windupload').serialize());
	 $.ajax({
         type: "POST",
         dataType: "html",
         url: AjaxURL.val()),
         data: $('#windupload').serialize(),
         
     }
function qbupload(){
			var AjaxURL= "http://localhost:8080/aster/manager/newBonds/updateExcel"; 
			alert($('#qbupload').serialize());
			 $.ajax({
		         type: "POST",
		         dataType: "html",
		         url: AjaxURL.val()),
		         data: $('#qbupload').serialize(),
		         
	}	 
</script>
</body>
</html>


这是页面代码,里面有两个文件上传form,使用接口上传。因为后端传文件的时候要去传递2个参数(input hidden里的)和两个请求头。请问请求头怎么修改?

加载中
0
Allen_Ho
Allen_Ho
ajax里面带headers 这个参数可以吧?
返回顶部
顶部