shv22 shv22 - 1 year ago 80
Ajax Question

Ajax call on success not working

I have to convert a encrypted data response back to plain text.

For this I am using a ajax post call to get the data response and than on sucess passing that data response a decrypto function and getting back the response in plain text (this is the idea)

Now, when I created a Ajax post call and than passing that decrypto their on success nothing is happening

I am sure my decrypto is working

Here is working fiddle for that

Now, problem is in the Ajax. I have only once make an Ajax call so I pretty much sure there will problem in that. But I am not getting that.

This is my code-

JS -

$('#action-button').click(function() {
var settings = {
async: true,
crossDomain: true,
url: "",
method: "POST",
headers: {
"cache-control": "no-cache",
"postman-token": "ac20a050-a8c8-6d58-4350-66141d519394",
"content-type": "application/x-www-form-urlencoded"
data: {
"username": "aHRtbHVzZXIx",
"password": "SHRtbDIwMTY="

$.ajax(settings).done(function (response) {
decrypted = decryptByDES(response,DES);

function decryptByDES(cipherTextString, keyString) {
var keyHex = CryptoJS.enc.Utf8.parse(keyString);

var decrypted = CryptoJS.DES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(cipherTextString)
}, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7


return decrypted.toString(CryptoJS.enc.Utf8);


<script src="tripledes.js"></script>
<script src="mode-ecb.js"></script>

<button id="action-button">Click me to load info!</button>
<div id="info"></div>

Can anyone please help me with that??

Answer Source

Try to include jquery in your page.

<script src=""></script>