0

我发现了这个问题,但是我的解决方案不起作用。变量 d0 和 d1 被填充,但在代码创建和拼接数组存储位置之后。因此,我收到一个错误,即 d0 和 d1 未定义。有什么解决办法吗?谢谢帮助

Javascript:

    $(function () {


        $.get("/Map/GetJsonData", function (data) {
            storeLocations = [];
            var d0 = data[0].Delay;
            var d1 = data[1].Delay;


        });

        var storeLocations = new Array();
        storeLocations.splice(storeLocations.length, 0, d0);
        storeLocations.splice(storeLocations.length - 1, 0, d1);


}
4

1 回答 1

0

Take these debugging steps:

  1. First of all, call your action via browser. See if there is any result showing as JSON or not. Simply enter the full URL, like http://domain/Map/GetJsonData
  2. If you think you really have data in your database, but data is not shown in the browser, then try to debug through Visual Studio. Breakpoints are to rescue here.
  3. If you get data back via browser, then try simple $.get method of jQuery. Even test $.ajax with parameters.
于 2013-11-15T07:18:33.250 回答