扫码关注官方订阅号
求一个纯js 发起ajax post请求的例子 还有post请求的参数 有什么要注意的???
走同样的路,发现不同的人生
$.ajax({ type: 'Post', url: '/api/characters', data: {name:name,gender:gender} }) .done((data) => { this.actions.addCharacterSuccess(data.message); }) .fail((jqXhr) => { this.actions.addCharacterFail(jqXhr.responseJSON.message); });
传统一点的
$('#btn_sumbit').click(function() { var loginform=$("#login_form"); var loginParam = loginform.serialize(); //alert(loginParam); $.ajax({ type:'post', url:'{:U("Auth/login")}', data:loginParam, async:false, cache:false, dataType:'json', success:function(data){ if(data.status==1){ isLogin=true; restPageStatus(isLogin); $('#loginModal').modal('hide'); } else { var alertinfo=$('.alert-danger'); alertinfo.empty(); alertinfo.append(data.info); alertinfo.show(); } } }); });
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
传统一点的