标签:出错 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>
标签:出错 pos erro ext encrypt log username cti The
原文地址:https://www.cnblogs.com/sea-stream/p/11490174.html