ajax 获取接口返回值


code

$.ajax({
      type: "POST",
      url: "/encrype",
      contentType: "application/json",
      data: JSON.stringify(json), /*传给后端的数据格式json*/
      dataType: "json", /*后端返回的数据格式json*/
      success: function(data){
          res=data.encryped;
          console.log("c-------> server返回加密后的字符串------>",res);
          var decrypt = new JSEncrypt();
          decrypt.setPrivateKey($('#privkey').val());
          var uncrypted = decrypt.decrypt(res);
          console.log("d-------> js解密c后的字符串------>",uncrypted);
          // Now a simple check to see if the round-trip worked.
          if (uncrypted == $('#input').val()) {
          }
          else {
            alert('Something went wrong....');
          }
      },
      error: function (message) {
          console.log("error");
      }
    });

 

 

 

 

 

 

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM