Ajax请求接口的方式

ajax请求方式

//1、get
$.ajax({
  type: "GET",
  url: "test.js",
    success: function(msg){
     alert( "Data Saved: " + msg );
   }
});

//2、post
$.ajax({
   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
});

post请求方式

$.post({
    url: "test.php",
    data:{ name: "John", time: "2pm" },
    success:function(data){
          alert( data );
    }
});  

get请求方式

$.get({
    url: "test.php",
    data:{ name: "John", time: "2pm" },
    success:function(data){
          alert( data );
    }
});  
posted @ 2021-10-10 18:26  有何和不可  阅读(449)  评论(0)    收藏  举报