AJAX之发送GET请求

时间:2023-03-09 05:52:52
AJAX之发送GET请求
用jquery发送get请求
function AjaxSubmit1() {
$.ajax({
//用jQuery发送
url: '/app04/ajax1/',
type: 'GET',
data: {'p':123},
success:function () { }
})
} 原生发送get请求
function AjaxSubmit2() {
//原生发送请求
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
// 接收完毕服务器返回的数据
console.log(xhr.responseText); }
};
xhr.open('GET', '/app04/ajax1?p=123');
xhr.send(null);
}