码迷,mamicode.com
首页 > 其他好文 > 详细

dfd

时间:2019-09-09 10:27:04      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:出错   pos   erro   ext   encrypt   log   username   cti   The   

 

<!DOCTYPE html>
<html>
<head>
  <script src="crypto-js.min.js"></script>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
  <script src="http://passport.cnblogs.com/scripts/jsencrypt.min.js"></script>
  <script type="text/javascript">
    // 使用jsencrypt类库加密js方法,
    function encryptRequest(reqUrl, data, publicKey) {
      var encrypt = new JSEncrypt();
      encrypt.setPublicKey(publicKey);
      // ajax请求发送的数据对象
      var sendData = new Object();
      // 将data数组赋给ajax对象
      for (var key in data) {
        sendData[key] = encrypt.encrypt(data[key]);
      }
      console.info(sendData);
      $.ajax({
        url: reqUrl,
        type: post,
        data: sendData,
        dataType: json,
        //contentType: ‘application/json; charset=utf-8‘,
        success: function (data) {
          console.info(data);
        },
        error: function (xhr) {
          //console.error(‘出错了‘);
        }
      });
    }
    // Call this code when the page is done loading.
    $(function () {
      $(#testme).click(function () {
        var data = [];
        data[username] = $(#username).val();
        data[passwd] = $(#passwd).val();
        var pkey = $(#pubkey).val();
        encryptRequest(/, data, pkey);
      });
    });
  </script>
</body>
</html>

 

dfd

标签:出错   pos   erro   ext   encrypt   log   username   cti   The   

原文地址:https://www.cnblogs.com/sea-stream/p/11490174.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!