本文整理汇总了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");
});
}