jQuery Promise then not working after AJAX

前端 未结 2 1579
眼角桃花
眼角桃花 2021-02-10 13:55

I have my Promise defined as so:

myFunc = function() {
    $.getJSON(\"./rest/api/some/url\", function(json, textStatus) {
        console.log(\"AJAX call hit!\"         


        
2条回答
  •  余生分开走
    2021-02-10 14:26

    You need promise-compatible object functon myFunc() returns null

    $.when(null).then(function() {
        console.log("Then block hit!");
    });
    

    output : Then block hit!

    Try

    return $.getJSON("...
    

提交回复
热议问题