Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. $(function () {
  2. $(".btn-post").click(function (e) {
  3. e.preventDefault();
  4. $.ajax({
  5. type: "POST",
  6. url: "http://localhost:59216/api/Pizza",
  7. data: JSON.stringify({
  8. toppings: "pineapple",
  9. price: 10.99
  10. }),
  11. contentType: "application/json;charset=utf-8"
  12. }).done(function (result) {
  13. $(".result").text('Ajax result: pizza object was added successfully with id number ' + result.id + ', and ' + result.toppings + ' topping for the price of ' + result.price + '$');
  14. }).fail(function () {
  15. alert('An error has occurred');
  16. });
  17. });
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement