TanYong

利用jQuery发送ajax异步请求

//很少接触JQuery的Ajax请求  就想着记录一下 到时候有用
$(\'form\').submit(function (e) { // 阻止表单默认提交 e.preventDefault(); var name = $(\'#name\').val(); var password = $(\'#password\').val(); var data = JSON.stringify({"name": name, "password": password}); // 异步发送数据 $.ajax({ // 数据传送方式 type: \'POST\', contentType: "application/json; charset=utf-8", // 数据处理文件 url: \'process.php\', // JSON格式数据 data: data, dataType: \'json\', // @msg: 数据返回值 success: function (msg, status) { console.log(msg); }, // Degbug error: function (xhr, desc, err) { console.log(xhr); console.log("Details: " + desc + "\nError:" + err); } }); });

 

分类:

技术点:

相关文章:

  • 2021-11-01
  • 2021-10-07
  • 2021-11-23
  • 2021-12-02
  • 2021-10-28
  • 2021-10-20
  • 2021-10-04
猜你喜欢
  • 2021-08-11
  • 2021-12-02
  • 2021-11-22
  • 2021-10-28
  • 2021-12-02
  • 2021-11-29
相关资源
相似解决方案