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