How does one return data to the original caller function in Javascript?

前端 未结 5 2126
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-18 15:42

I have a problem returning data back to the function I want it returned to. Code below:

function ioServer(request_data, callback)
{
    $.ajax({
        cach         


        
5条回答
  •  时光取名叫无心
    2020-12-18 15:56

    Since this is an asynchronous request, it does not directly return a value like that and it isn't possible.

    The way to approach this is to have some method which performs any actions you need on the fetched data, instead of attempting to have a return value which will not work.

提交回复
热议问题