Ajax JSONP Example

An example of an AngularJS App making AJAX requests with JSONP

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular-resource.min.js"></script>
<div ng-controller="myCtrl">
    <fieldset ng-view>
        <legend>JSONP Example using jsfiddle echo</legend>
        <label for="foo">foo:</label>
        <input type="text" ng-model="foo" />
        <br />
        <button ng-click="getData()">GET Request</button>
        <button disabled="disabled" title="POST Requests are unavailble with JSONP">POST Request</button>
    </fieldset>
    <br />
    <label for="echo">Echo'd Response</label>
    <textarea name="echo" ng-model="response" disabled="disabled"></textarea>
</div>

CSS

textarea {
    height:50px;
    width:100%;
}