0

could you please tell me why then function not call ?I try to fetch json data from file here is my code https://plnkr.co/edit/3APaLWC7QkNuvxHirL14?p=preview

function abc(){
  return check();
}
function check(){
   return  $.ajax({
            url:'data.json',
            success: function (json) {
              return json;
            }
        })
}
$(function(){
  abc().then(function(d){
    console.log(d)
  })
})
user944513
  • 12,247
  • 49
  • 168
  • 318
  • Why you think `.then()` (or it's callback) isn't executed? The script works (@MichalPerlakowski) and the content of `data.json` is printed in the console – Andreas Jun 07 '17 at 17:03
  • @Andreas Trying to do `return json;` in a callback function clearly shows that the OP has no idea how asynchronous functions work. – Michał Perłakowski Jun 07 '17 at 17:04

0 Answers0