一、定义
AJAX = 异步 JavaScript 和 XML(Asynchronous JavaScript and XML;简短地说,在不重载整个网页的情况下,AJAX 通过后台加载数据,并在网页上进行显示
二、用法
$("#id").load()
load(url,data,function(response,status,xhr))
$("button").click(function(){ ?$("div").load(‘demo_ajax_load.txt‘);});
$.get();
$.get("http://datainfo.duapp.com/shopdata/getclass.php",function(data){ ???????????console.log(data) ???????})
$.get("http://datainfo.duapp.com/shopdata/getuser.php?userID=f66",function(data){ ???????????console.log(data) ???????},"JSONP");$.get("http://datainfo.duapp.com/shopdata/getCar.php",{userID:"f66"},function(data){ ???????????console.log(data) ???????},"JSONP")
$.post(URL,data,callback);
$.post("http://datainfo.duapp.com/shopdata/getuser.php?userID=f66",function(data){ ???????????console.log(data) ???????},"JSONP"); ???????$.post("http://datainfo.duapp.com/shopdata/getCar.php",{userID:"f66"},function(data){ ???????????console.log(data) ???????},"JSONP")
$.ajax();
$.ajax({ ?????type:"get", ?????url:"", ?????function(data){ ???????????console.log(data) ?????????????} ?});
$.getJSON();
$.getJSON("http://datainfo.duapp.com/shopdata/getCar.php?userID=f66&callback=?",function(data){ ??????????console.log(data) ???????}) ???$.getJSON("pro.json",function(data){
console.log(data) sortPrice(data); ????data.sort(function(a,b){ ???return a.price - b.price; ??}) ??????console.log(data) ?????})
$.getScript();
????????$.getScript("test.js",function(){ ???????????????setTimeout(function(){ ???????????????????alert(2) ???????????????},2000) ???????????})
ajax
原文地址:https://www.cnblogs.com/justSmile2/p/9720333.html