用jquery的ajax组件可以很快实现js发送请求。参考以下JS代码:
<script>
$(function(){
var url = "http://abc.com";//你的请求url
//发起get请求
$.get(url, function(res){
console.log('ajax_get========', res);
},'json');
});
//发起post请求
var postdata = {
'id':'123'
};//post提交的参数
$.post(url, postdata, function(res){
console.log('ajax_get========', res);
},'json');
});
</script>