1. 程式人生 > >AngularJs最簡單解決跨域問題jsonp案例

AngularJs最簡單解決跨域問題jsonp案例

var app = angular.module('app', []); app.controller('appCtrl', ['$scope', function ($scope) { $http({ method: 'JSONP', url: 'http://www.b.com/test.php?callback=JSON_CALLBACK', }).success(function (msg) { console.log(data); }); //或者
$http .jsonp('http://www.b.com/test.php?callback=JSON_CALLBACK') .success(function (msg){ console.log(msg); }); }]);