*測試 "不同網域" 請求api的方法:
1.進入
https://api.jquery.com/
2.打開瀏覽器的console(主控台)輸入:
(ajax的url為api網址)
$.ajax({
url: 'http://localhost/animal/public/api/news'
}).done(function(data) {
console.log(data);
});
=============================================
$.ajax({
type: 'POST',
url: 'http://localhost/animal/public/oauth/token',
data: {grant_type: 'password', client_id: '2', client_secret: 'bKT4uk7TGKrih4FGTlt01fdbpPc6f1B2Ry4j', username: 'arc99@gmail.com', password: 'aaa1234', scopes: ''},
success: function(msg) {
alert('Data Saved: ' + msg);
}
});
=============================================
jQuery Ajax
https://www.fooish.com/jquery/ajax.html
沒有留言:
張貼留言