jquery发送post请求
function AjaxSubmit3() {
            //jquery发送post请求
            $.ajax({
                url: '/app04/ajax1/',
                type: 'POST',
                data: {'p': 123},
                success:function () {

                }
            })
        }

原生发送post请求
 function AjaxSubmit4() {
        //原生发送post请求
            var xhr = new XMLHttpRequest();
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4){
                    console.log(xhr.responseText);
                }
            }
            xhr.open('POST', '/app04/ajax1/');
             //需要加请求头, 设置请求头
            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset-UTF-8');
            xhr.send('p=123');
        }

 

posted on 2018-06-19 15:08  wy0925  阅读(162)  评论(0)    收藏  举报