Ajax往后台传参数,无参数,一个参数,多个参数,一个对象等

it2026-08-18  9

原文:http://www.cnblogs.com/chenwolong/p/Get.html

//无参数请求-简单示例 $(document).ready(function () { $.ajax({ url: "http://localhost:9953/api/Person/Get", type: "post", contentType: "application/json", dataType: "text", data:{}, success: function (result,status) { if (status == "success") { alert(result); } }, error: function (error) { alert(error); } }); }); //单个参数传递- data: {"":"3"}, 这种方式也竟然正确 $(document).ready(function (data) { $.ajax({ url: "http://localhost:9953/api/Person/GetById", type: "post", contentType: "application/json", dataType: "text", data: {Id:"3"}, success: function (result,status) { alert(result) }, error: function (error) { alert(error); } }); });

 

 

转载于:https://www.cnblogs.com/ZkbFighting/p/8651536.html

最新回复(0)