1
嗨我在我的項目中使用https://github.com/getmeuk/ContentTools庫,在文檔中使用普通的js發送ajax請求,我想用jquery發送數據,但我不知道如何那。如何通過jQuery在getcontenttools庫中發送ajax
這是在普通的JavaScript發送Ajax代碼:
// Send the update content to the server to be saved
onStateChange = function(ev) {
// Check if the request is finished
if (ev.target.readyState == 4) {
editor.busy(false);
if (ev.target.status == '200') {
// Save was successful, notify the user with a flash
if (!passive) {
new ContentTools.FlashUI('ok');
}
} else {
// Save failed, notify the user with a flash
new ContentTools.FlashUI('no');
}
}
};
xhr = new XMLHttpRequest();
xhr.addEventListener('readystatechange', onStateChange);
xhr.open('POST', '/x/save-page');
xhr.send(payload);
非常感謝你 –