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

后端 未结 4 604
醉酒成梦
醉酒成梦 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-27 16:48

    Add an async true attribute to your .ajax call:

        type: "POST",
        async: false, // ADD THIS
        url: "/Admin/GetCandidateName/",
    

    Also, you left off an "s" on success.

    That may do it.

提交回复
热议问题