【www.gdgbn.com--jquery】

本文章来告诉你利用了$.ajax来与数据库教程交互或异步传送数据,更新数据,删除数据等利用了jquery ajax来实例在是方便了很多,简单几句代码就ok了。
加载js
$.ajax({
   type: "get",
   url: "test.js",
   datatype: "script"
 });
 
ajax保存数据
$.ajax({
   type: "post",
   url: "some.php教程",
   data: "name=john&location=boston",
   success: function(msg){
     alert( "data saved: " + msg );
   }
 });
 
ajax保存数据返回值更改htm内容

$.ajax({
  url: "test.html",
  cache: false,
  success: function(html){
    $("#results").append(html);
  }
});

加载数据同步。阻止浏览器的要求而被激活。最好是通过其他方式来阻止用户的交互时,同步是必要的

var html = $.ajax({
  url: "some.php",
  async: false
 }).responsetext;
 
例如:发送到服务器作为数据的xml文档。通过设置processdata选项为false,数据自动转换为字符串是可以避免的。

var xmldocument = [create xml document];
 $.ajax({
   url: "page.php",
   processdata: false,
   data: xmldocument,
   success: handleresponse
 });
 
 为发送数据到服务器的id,保存一些数据到服务器,并通知用户一旦它的完成。请注意,此用法 - 返回到一个变量的调用的结果 - 需要同步(阻塞)的要求! (异步:假)

bodycontent = $.ajax({
      url: "script.php",
      global: false,
      type: "post",
      data: ({id : this.getattribute("id")}),
      datatype: "html",
      async:false,
      success: function(msg){
         alert(msg);
      }
   }
).responsetext;

本文来源:http://www.gdgbn.com/wangyezhizuo/27279/