get,post,ajax

$.post(URL,data,callback);
$.post(URL,data,callback,'JSON');


$.get(URL,callback);

$("button").click(function(){
  $.post("demo_test_post.asp",
  {
    name:"Donald Duck",
    city:"Duckburg"
  },
  function(data,status){
    alert("Data: " + data + "\nStatus: " + status);
  });
});

$(selector).load(URL,data,callback);

$("#div1").load("demo_test.txt #p1");

把 "demo_test.txt" 文件中 id="p1" 的元素的内容,加载到指定的 <div> 元素中

$.ajax({ url: "test.html", context: document.body, success: function(){
        $(this).addClass("done");
      }});
$(document).ready(function(){
  $("#b01").click(function(){
  htmlobj=$.ajax({url:"/jquery/test1.txt",async:false});
  $("#myDiv").html(htmlobj.responseText);
  });
});
async
类型:Boolean
默认值: true。默认设置下,所有请求均为异步请求。如果需要发送同步请求,请将此选项设置为 false。
注意,同步请求将锁住浏览器,用户其它操作必须等待请求完成才可以执行。
http://www.w3school.com.cn/jquery/ajax_ajax.asp



猜你喜欢

转载自blog.csdn.net/xinyuebaihe/article/details/80233187