Jquery: Return the value of a ajax call to caller function?

后端 未结 4 595
醉酒成梦
醉酒成梦 2021-01-27 15:53

Im trying to return the value that a $ajax call returns, from a function but it only returns \"undefined\". If a alert the \"reponse\" from the ajax call it returns the rigth va

4条回答
  •  不思量自难忘°
    2021-01-27 16:41

     $.ajax({
            type: "POST",
            url: "/Admin/GetCandidateName/",
            data: { 'candidateID': candidateID },
            success: function(response) {
                return response;//USE THIS
    
                //THIS WILL RETURN FROM THE FUNCTION WITHOUT RETURNING ANY VALUE
                //return;
            },
    

提交回复
热议问题