Ajax异步数据交互📅 2025-01-01  |  👁 3862 次浏览

原生Fetch API

fetch('/api/data')
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error(error));

POST请求

fetch('/api/submit', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ name: 'test' })
});

应用场景

在CMS中用于:无刷新提交表单、加载更多内容、搜索建议、实时验证等。

芒阳网络团域cms开发中心

Copyright © 2023 刀客CMS内容管理系统