本文整理匯總了TypeScript中jQuery.getJSON函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getJSON函數的具體用法?TypeScript getJSON怎麽用?TypeScript getJSON使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getJSON函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: loadMovies
loadMovies(): Array<Movie> {
let movies: Array<Movie> = [];
$.getJSON('/movies').then(data => {
data.forEach(movie => movies.push(new Movie(movie.title, movie.year, movie.rating)));
})
return movies;
}
示例2: loadNotes
function loadNotes(){
$.getJSON('notes.json',function(data){
data.notes.forEach(note =>{
$('#notes').append(`<li class="${note.id}">${note.title}</li>`);
})
});
}
示例3: get
export function get(period: Task.IPeriod, groupBy: Property) {
const data = {
begin: period.begin,
end: period.end,
group_by: propertyToRequestNames[groupBy],
};
return $.getJSON("/rest/v1/report/", data).then(parseReportJson);
}
示例4: loadNote
function loadNote(title:string){
var searchString = `http://localhost:3000/notes?q=${title}`;
alert(searchString);
$.getJSON(searchString, function (data) {
$('#notes').append(`<li class="${data.note.id}">${data.note.title}</li>`)
});
}
示例5: function
socket.on("receive", function(msg) {
console.log(msg);
if (msg.type == connect.MessageType.RESPONSE) {
console.log("Respuesta para:", connect.MessageType[msg.content.type]);
console.log("Codigo de respuesta:", connect.ResponseCode[msg.content.code]);
}
else if (msg.type == connect.MessageType.NEW_CHAT) {
$.getJSON('../../tmp/room.json', (data) => {
if (data.room.name == msg.content.room)
$('#chat').append(`<li><b>${msg.content.user}: </b>${msg.content.message}</li>`);
});
}
});
示例6:
USERS_REFRESH: (store, action) => {
var state = store.getState();
$.getJSON(state.channelSubscribersUrl, results => {
var channelUsers = {};
var usersMap = {};
results.forEach(user => usersMap[user.userId] = user);
Object.keys(usersMap).forEach((userId) => {
const user = usersMap[userId];
user.channels.split(',').map(channel => {
var users = (channelUsers[channel] || (channelUsers[channel] = []));
users.push(user);
});
});
store.dispatch({ type: 'USERS_SET', channelUsers, users: channelUsers[state.selectedChannel] });
});
},
示例7: Promise
const promise : Promise<Array<MemberEntity>> = new Promise((resolve, reject) => {
$.getJSON('https://api.github.com/orgs/lemoncode/members', function(data) {
// do something with data
var members : Array<MemberEntity>;
members = data.map((gitHubMember) => {
var member : MemberEntity = new MemberEntity();
member.id = gitHubMember.id;
member.login = gitHubMember.login;
member.avatar_url = gitHubMember.avatar_url;
return member;
});
resolve(members);
});
});
示例8: Get
// =========================
// Send dispatch command to increment in one the async calls counter
// Execute the async call action
// On Success, On Error --> Send dispatch comment to decrement
// Return promise
// =========================
public Get(url : string)
{
var deferred = Q.defer<any>();
this._dispatcher(httpCallStarted());
// TODO: enhance this, better error handling
$.getJSON(url, function(data) {
this._dispatcher(httpCallCompleted());
deferred.resolve(data);
}.bind(this)
,function (err) {
this._dispatcher(httpCallCompleted());
deferred.reject(err);
}.bind(this)
);
return deferred.promise;
}
示例9: home
home() {
console.log("Service Called");
$.getJSON(FacilityURL + BookAtHome.Rnd *1000)
.done((data) => {
console.log("Success");
this.Items = new Models.Facilities(data.Facilities);
localStorage.setItem("Facilities", JSON.stringify(data.Facilities));
console.log("LocalStorage Updated");
})
.fail(() => {
this.Items = new Models.Facilities(Data.Facilities);
console.log("Failure");
}).always(() => {
var grid = new Views.GridView({
collection: this.Items
});
this.Layout.detail.show(grid);
console.log("Rendered");
});
}