Adam Halasz
Adam Halasz

Reputation: 58301

Set delay with javascript / ajax

I want to make a delay when the result comes in the note.

I have a form > input the user types his username in the input and I check with AJAX

if the username is available or not. If yes a note shows up near the input with the

result.

Please no jQuery!

Upvotes: 1

Views: 1450

Answers (1)

Daniel Vassallo
Daniel Vassallo

Reputation: 344291

You may want to use setTimeout() to display something after a short delay:

var delay = 1000;            // 1 second
var result = 'note here';    // the result from your AJAX response

setTimeout(function() { 
   document.getElementById('note').innerHTML = result; 
}, delay);

Upvotes: 2

Related Questions