简体   繁体   中英

How to return json result from function?

I am trying to return a Json request, but it is always null. I'm not sure what I am doing wrong...

  /* GetTasksByDateRange */
this.fnGetTasksByDateRange = function (dateFilter)
{
    /* Get tasks by date range */
    var oData = {};

    var jsonTaskData = $.getJSON('/Planner/Planner/GetTasksByDateRange', { 'dateFilter': dateFilter }, function (jsonTaskData)
    {
        oData = jsonTaskData;
    });

    return oData;
}

oData hasn't been set at that point. You will need to have the asynchronous function call another, passing it the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM