<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <button id="btn">发送请求</button> <script src="/js/jquery.min.js"></script> <script> var params = { name: 'zs', age: 18 } $('#btn').on('click', function() { // console.log(1); $.ajax({ type: 'post', url: '/user', // data: { // name: 'zs', // age: 18 // }, // data: 'name=zs&age=18', data: JSON.stringify(params), contentType: 'application/json', success: function(response) { console.log(response); }, error: function(xhr) { console.log(xhr); } }) }) </script> </body> </html>
标签:function,console,log,ajax,参数,zs,data,请求 From: https://www.cnblogs.com/wangxianwen/p/16743058.html