1
var encodedAccount = '';
function encodeUsername() 
{
    encodedAccount=  encrypt(document.getElementById('account').value);
    alert(encodedAccount);
}

the function encrypt is async ajax function. the alert is not returning a value , it's still '' Any Idea ? Thanks

1 Answer 1

5

Asynchronous functions generally don't return values. They usually accept a callback function that fires when the function is done (usually when when HTTP response comes back in the case of Ajax).

You need to find out how the encrypt function expects to be used and conform to its expectations.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Quentin, I will review the function and try to use callback

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.