面向初学者的ajax基础知识

面向初学者的ajax基础知识,ajax,jquery,asp.net-ajax,ajaxcontroltoolkit,Ajax,Jquery,Asp.net Ajax,Ajaxcontroltoolkit,我有上面的代码,我在网上搜索,但我不知道如何解释它的用途。有没有ajax基础教程一步一步地解释什么 $.ajax()的意思是,type:Get做什么,data:…做什么等等 它正在对远程页面进行ajax(异步)调用 $.ajax({ type: "GET", data: "id="+id+"&id-other="+id-other, url: "ajax1.php" }).done(function(data){ $("#div").html(data);

我有上面的代码,我在网上搜索,但我不知道如何解释它的用途。有没有ajax基础教程一步一步地解释什么

$.ajax()
的意思是,type:Get做什么,data:…做什么等等

它正在对远程页面进行ajax(异步)调用

$.ajax({
    type: "GET",
    data: "id="+id+"&id-other="+id-other,
    url: "ajax1.php"
}).done(function(data){
    $("#div").html(data);
});
这是一个HTTP Get请求。表单数据将在url中编码为查询字符串值

type: get
这是传递到服务器页面的数据

data: "id="+id+"&id-other="+id-other
php是处理ajax请求并返回的服务器页面

 url: "ajax1.php"
一旦ajax调用完成,将执行done事件中的代码。在本例中,我们将从ajax调用获得对名为data的变量的响应。我们将其设置为id为div的某个HTML元素的innerhtml

有关更多信息,请阅读此链接:


它非常简单,我们首先声明AJAX函数,然后声明方法(get或post-就像html表单一样),
数据
用于通过URL传递的参数
URL
是被调用的文件(就像表单中的操作一样)。这将调用ajax1.php文件并返回一些数据,这些数据将在success函数或done函数中返回。在您的例子中,
数据
是从您的php文件返回的数据。

谢谢,您能给我一个ajax1.php文件的示例吗?例如,上面的ajax查询是将2个id保存到数据库中,我不知道ajax1.php可能是什么written@SesamaSesame:对不起,我不是php高手。这个页面可以是一个php页面,它读取查询字符串vlaues并执行操作。
.done(function(data){
   $("#div").html(data);
})
$.ajax({
        type: "GET",
        data: "id="+id+"&id-other="+id-other,
        url: "ajax1.php"
    }).done(function(data){
        $("#div").html(data);