function saveInfo(id){
var userID = id;
var userEmail = $(‘.userEmail‘).val();
var userName = $(‘.userName‘).val();
var dataJSON ={"userID": userID,"userEmail": userEmail,"userName": userName};
$.ajax({
type:‘POST‘,
url:‘../../Services/AjaxServices.svc/SaveUser‘,
data:JSON.stringify(dataJSON),
contentType:‘application/json; charset=utf-8‘,
dataType:‘json‘
});
returnfalse;
}`
ajax优点:无刷新,良好用户体验,可以减小网络的整体流量,节约资源
ajax缺点:破坏浏览器后退按钮的正常行为(IE8修正),对串流媒体的支持没有FLASH,java apple好
ajax本质上是由XMLHttpRequest对象直接与服务器进行通信
时间: 2024-12-10 15:47:25