O'Reilly logo

Ext JS 4 Web Application Development Cookbook by Stuart Ashworth, Andrew Duncan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading cross-domain data with a Store

Now that we have a Model, the next step is to load some data into it for use throughout our applications. An Ext.data.Store is an ideal way of doing this. It has all the features we require to load and save data and can be linked with a proxy to determine how we may wish to do this (for example, through AJAX, JSONP, and so on)

This recipe will demonstrate how to load data that originates from a different domain directly into your application using JSONP. We are going to use Flickr's API feeds for our cross-domain data.

Note

JSONP is a method for making cross-domain AJAX requests.

How to do it...

  1. Start by defining a model to define the data we are loading:
    Ext.define('Flickr', { extend: 'Ext.data.Model', fields: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required