9951 explained code solutions for 126 technologies

javascriptAjax post json data

fetch('/backend.php', {
  method: 'post',
  body: JSON.stringify({name: 'Donald'})
}).then(function(r) {
  return r.json();
}).then(function(data) {
});ctrl + c

backend script to receive posted data

method: 'post'

set ajax request method to post

{name: 'Donald'}

this will be posted as JSON

return r.json()

server response will be processed as JSON


replace with your code processing data (response from server as JSON object)