- 时间:2020-03-16 07:24 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:js jquery ajax的几种用法总结(及优缺点介绍)
这篇文章,是我不知道什么是ajax到熟练运用ajax的一个历程。
[b]一,最原始的方式来运用ajax
[/b]
[url=javascript:]这样就可以不用在html里面写onclick事件了
[b]三,jquery的ajax
[/b]1)
$.ajax({
type: "POST",
url: "test.php", //调用的php文件
data: "name=zhang",
success: function(msg){ //回调函数
alert( "Data Saved: " + msg ); //这里是操作
}
});
2)
//调用test.php文件,传个参数,data是返回的数据
$.post("test.php", { name: "zhang"},
function(data){
alert("Data Loaded: " + data);
});