zoukankan      html  css  js  c++  java
  • dfd

    <!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>
  • 相关阅读:
    搜索框下拉列表
    定时器修改button标题闪烁
    按钮设置文字图片排版
    SSKeychain
    IQKeyboardManager
    App内存性能优化
    支付宝集成
    友盟分享
    iOS 线程同步 加锁 @synchronized
    iOS 线程同步-信号量 dispatch_semaphore
  • 原文地址:https://www.cnblogs.com/sea-stream/p/11490174.html
Copyright © 2011-2022 走看看