[转] JQUERY中简单使用AJAX

JQuery第14天里说到了Ajax:同时给了几个读取数据的例子,jquery没有Prototypre的严谨与规范,但利于普通开发的快速上手,也算是各有千秋吧,要是结合两者,我想更是事倍功倍,虽然说两者加起来快近80K,但这个年代带宽应该不是问题了,AJAXModule

I’m trying something a little different today. It took me a while to figure out why I couldn’t open a free account with YouTube for about 3 weeks but now that it’s all straightened out I thought I’d upload a video where I walk you through some of the basic ways you could use jquery to add AJAX functionality to your site.

The video is short because my understanding of YouTube is that I have to limit the file to 10 minutes. Not everything I’ve said in the tutorial is 100% correct. There are minor mistakes such as the part where I call cgi a “server side script” when it would be more accurate to say “server side language”.

Cut me some slack… woodya?英文全文

Demos » AJAX Plugin

Loaded from an HTML File

Code:

$("div#html").load("ajax-test.html");
Loaded from an XML File

Code:

$.get("ajax-test.xml",function(xml){
var text = $("title",xml).text();
$("div#xml").html("<h1>"+text+"</h1>");
});
Loaded from a Dynamic HTML File

Code:

$("div#dhtml").load("html.cgi",{name:"John"});
Loaded from a Dynamic XML File

Code:

$.post("XML.cgi",{
name: "John"
},function(xml){
var text = $("title",xml).text();
$("div#dxml").html("<h2>"+text+"</h2>");
});
Loaded from a Text File

Code:

$.get("ajax-test.txt",function(txt){
$("div#txt").html("<h1>"+txt+"</h1>");
});

Read: 213

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注