AJAX初学者入门 [英] ajax basics for beginners

查看:233
本文介绍了AJAX初学者入门的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$.ajax({
    type: "GET",
    data: "id="+id+"&id-other="+id-other,
    url: "ajax1.php"
}).done(function(data){
    $("#div").html(data);
});

我有code片上面,我在网上搜索,但我不知道怎么解释它是什么。有没有AJAX基础由什么结果一步一步讲解的任何教程
$阿贾克斯()手段,是什么类型:获取做什么数据:.. 等呢?

I have the code piece above, I search the web but I don't know how to explain what it is for. Is there any tutorials of ajax basics explaining step by step of what
$.ajax() means, what type:Get does, what data:... does etc ?

推荐答案

据作出的 AJAX(异步)拨打到远程页面。

It is making an ajax (asynchronous) call to a remote page.

type: get

这是一个HTTP GET请求。表单数据将在连接URL作为查询字符串值codeD。

It is a HTTP Get request. The form data will be encoded in the url as query string values.

data: "id="+id+"&id-other="+id-other

此数据被传递到服务器页

This the data being passed to the server page

 url: "ajax1.php"

ajax1.php是处理Ajax请求和reponds回服务器页面,

ajax1.php is the server page which handles the ajax request and reponds back,

.done(function(data){
   $("#div").html(data);
})

在code该做的事件中,一旦将Ajax调用完成后执行。在这种情况下,我们会从AJAX调用给一个变量称为数据的响应。我们正在设置了一些HTML元素用一个id的div的innerHTML。

The code which inside the done event will be executed once the ajax call is completed. In this case we will get the response from the ajax call to a variable called data. We are setting that as the innerhtml of some HTML element with an id div.

阅读此链接了解更多信息: http://api.jquery.com/jQuery.ajax/

read this link for more info : http://api.jquery.com/jQuery.ajax/

这篇关于AJAX初学者入门的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆