Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Issue with jsonp

$
0
0
I'm trying to get data from a service that returns it wrapped in a function but it doesn't seem to be working and I'm not sure why. I can see the data coming back fine, but then nothing else happens. Is there something else I need to do? Here's my setup:


  1.  Cat = can.Model({
        findAll: 'GET  caturl',
        dataType: 'jsonp'
      }, {});


  1. Catlist = can.Control({
        init: function() {
            this.element.html(can.view('images/js/mn/temps/catlist.ejs', {
              catdata: this.options.catdata.cats
            }));
          }
      });


  1. Cat.findAll({}, function(catResponse) {
            new Catlist('.mn_cats', {
              catdata: catResponse
            });
          });

The json file looks something like this:
  1. callBack(
  2. {
      "cats": [
           {
            "name": "Sports & Recreation ",
            "id": "",
            "searchName": "",
            "children": [
              {
                "name": "Exercise & Fitness",
                "id": "61",
                "searchName": "Exercise-Fitness"
              },
              {
                "name": "Sports & Outdoors",
                "id": "21",
                "searchName": "Sports-Outdoors"
              },
              {
                "name": "Toys & Games",
                "id": "34",
                "searchName": "Toys-Hobbies"
              }
            ]
          },
           {
            "name": "Travel ",
            "id": "",
            "searchName": "",
            "children": [
              {
                "name": "Car Rentals",
                "id": "66",
                "searchName": "Car-Rentals"
              },
              {
                "name": "Cruises",
                "id": "48",
                "searchName": "Cruises"
              },
              {
                "name": "Flights",
                "id": "64",
                "searchName": "Flights"
              },
              {
                "name": "Food & Dining",
                "id": "42",
                "searchName": "Food-Dining"
              },
              {
                "name": "Hotels & Accommodations",
                "id": "53",
                "searchName": "Hotels-Accommodations"
              },
              {
                "name": "Travel Accessories",
                "id": "24",
                "searchName": "Travel Accessories"
              },
              {
                "name": "Vacation Packages",
                "id": "58",
                "searchName": "Vacation-Packages"
              }
            ]
          }
      ]
    }

This works fine without the callback.

Viewing all articles
Browse latest Browse all 3491

Trending Articles