0

I'm trying to call a controller action from javascript to get data in json format. I guess it should be pretty clear using $.getJSON function. But it doesn't work in my code. Is there anyone who can explain me what is wrong?

IndexController action

    public function jsonAction() 
    {
        $this->_disableView();

        $data[0]["name"] = "test";
        $data[0]["lat"] = 50.080746;
        $data[0]["long"] = 14.426373;

        echo json_encode($data);
    }

When I test it on url domain/index/json I see json as expected. Now the relevant script in document ready function:

    $.getJSON("index/json",function(data){
       alert("hello");
    });

But no alert is shown. In the console I can see

Uncaught TypeError: jQuery(...).asmSelect is not a function
tereško
  • 58,060
  • 25
  • 98
  • 150
JanaMaha
  • 13
  • 3

1 Answers1

0

GOT IT! I was missing slash at the behinning $.getJSON("/index/json",function(data){});

JanaMaha
  • 13
  • 3