admin管理员组文章数量:1125013
I found below code in a Plugin.
const sent_urls = () => {
const formData = new FormData();
formData.append('action', 'start_parsing');
formData.append('of_start_parsing_nonce', of_start_parsing_nonce.value);
formData.append('urls', urls.slice(offset, offset + limit));
formData.append( 'category_fans', category_fans );
fetch(ajaxurl, {
method: 'POST',
body: formData
}).then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
}).then(data => {
if (data.error) {
throw new Error(data.error);
}
if (!data.result) {
throw new Error('Unknown error');
}
added += data.result.added;
exists += data.result.exists;
error_urls = error_urls.concat(data.result.error);
offset += limit;
count_urls.textContent = 'Imported ' + all_urls + ' urls. ' + 'Added ' + added + ' urls. Exists ' + exists + ' urls. ' + 'Error ' + error_urls.length + ' urls.';
if (offset >= urls.length) {
enable();
alert.show_success('Parsing complete. Added ' + added + ' urls. Exists ' + exists + ' urls.');
if (error_urls.length > 0) {
textarea.value = error_urls.join('\n');
} else {
textarea.value = '';
}
offset = 0;
added = 0;
exists = 0;
error_urls = [];
return;
} else {
sent_urls();
}
}).catch(error => {
enable();
alert.show_warn(error);
});
}
This code is create a Post.
How this AJAX Form submitted ?
How a new post is created in WordPress ?
本文标签: postsCode understanding
版权声明:本文标题:posts - Code understanding 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736605091a1945305.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论