开发者

How to return json result from function?

开发者 https://www.devze.com 2023-02-08 14:56 出处:网络
I am trying to return a Json request, but it is always null. I\'m not sure what I am doing wrong... /* GetTasksByDateRange */

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消