1. 程式人生 > >jquery的ajax實現PUT與DELETE請求

jquery的ajax實現PUT與DELETE請求

實現PUT 

$.ajax({
  url: "http://localhost:10320/api/Person/4",
  type: "POST",
  data: JSON.stringify(whatever),
  headers: { 
      "Content-Type": "application/json",
      "X-HTTP-Method-Override": "PUT" }, //PUT,DELETE
})

實現DELETE

$.ajax({
  url: '/test',
  type: 'DELETE',
  data: {}
});