0

I have found the issue however my solution does not work. The variables d0 and d1 get populated but after the code creates and splices the array storelocations. Therefore, I get an error that d0 and d1 is undefined. Any solutions? thx for the help

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);


}
3
  • "However, the data is not being passed" - And what actually does happen? If you add console.log(data) as the first line of your callback function what does it show?
    – nnnnnn
    Commented Nov 15, 2013 at 7:00
  • Make sure Clinics is filled up correctly or are you missing something on url (may be ../Map/GetJsonData), try using $.get("/Map/GetJsonData", function (data) {}), this may not solve your issue but saves some cycles. Commented Nov 15, 2013 at 7:10
  • if I add document.write(d0); inside the $.get it prints out the correct information. Commented Nov 15, 2013 at 16:38

1 Answer 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.
1
  • Good response here. Just to add for user2138160 - F12 in most browsers will bring up the developer tools which will allow you to debug javascript fairly well. If you are using Firefox, you may want to download Firebug for debugging also.
    – JJJCoder
    Commented Nov 15, 2013 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.