惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
S
Secure Thoughts
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Troy Hunt's Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
博客园 - 司徒正美
NISL@THU
NISL@THU
小众软件
小众软件
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
T
Threat Research - Cisco Blogs
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园_首页
罗磊的独立博客
S
Securelist
N
News | PayPal Newsroom
大猫的无限游戏
大猫的无限游戏
T
Tenable Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
爱范儿
爱范儿
Spread Privacy
Spread Privacy
V2EX - 技术
V2EX - 技术
J
Java Code Geeks
V
V2EX
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
I
Intezer
腾讯CDC
P
Privacy & Cybersecurity Law Blog
SecWiki News
SecWiki News
Google DeepMind News
Google DeepMind News
P
Palo Alto Networks Blog
Cloudbric
Cloudbric
Apple Machine Learning Research
Apple Machine Learning Research
N
News and Events Feed by Topic
Latest news
Latest news
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园 - 【当耐特】
Last Week in AI
Last Week in AI
The Cloudflare Blog

博客园 - music000

Flash Chart 谨防 url 传递参数未编码(转码)产生的陷阱 OSI七层网络模型与TCP/IP四层网络模型 一些数据库理论知识 Sqlserver中Compute By子句用法分析 数据查询的另类需求 A Preview of HTML 5 CSS Sprites 15 Rules for Faster-Loading Web Sites 关于"多级目录(分类)"的一些想法 ----- 实现方法 金额转换:阿拉伯数字转中文(SQL存储过程) 金额转换:阿拉伯数字转中文(javascript) 这两天不爽——公车上被误认为色狼、游泳撞破上嘴唇 如何获取字段中分隔符的个数?(sql语句) 关于GridView导出Excel的一些问题(采用Ajax出现的的问题及解决方法) - music000 - 博客园 固定表头 Bubble in JavaScript DOM Reg-日期 安装 WebDesigner 之后,ASPNET 帐户没有对 IIS 的访问权。
分享:使用JQuery进行跨域请求
music000 · 2010-01-24 · via 博客园 - music000

 1   function doAjax(url,msg,container){
 2     // if the URL starts with http
 3     if(url.match('^http')){
 4       // assemble the YQL call
 5       msg.removeClass('error');
 6       msg.html(' (loading...)');
 7       $.getJSON("http://query.yahooapis.com/v1/public/yql?"+
 8                 "q=select%20*%20from%20html%20where%20url%3D%22"+
 9                 encodeURIComponent(url)+
10                 "%22&format=xml'&callback=?",
11         function(data){
12           if(data.results[0]){
13             var data = filterData(data.results[0]);
14             msg.html(' (ready.)');
15             container.
16               html(data).
17                 focus().
18                   effect("highlight",{},1000);
19           } else {
20             msg.html(' (error!)');
21             msg.addClass('error');
22             var errormsg = '<p>Error: could not load the page.</p>';
23             container.
24               html(errormsg).
25                 focus().
26                   effect('highlight',{color:'#c00'},1000);
27           }
28         }
29       );
30     } else {
31       $.ajax({
32         url: url,
33         timeout:5000,
34         success: function(data){
35           msg.html(' (ready.)');
36           container.
37             html(data).
38               focus().
39                 effect("highlight",{},1000);
40         },
41         error: function(req,error){
42           msg.html(' (error!)');
43           msg.addClass('error');
44           if(error === 'error'){error = req.statusText;}
45           var errormsg = 'There was a communication error: '+error;
46             container.
47               html(errormsg).
48                 focus().
49                   effect('highlight',{color:'#c00'},1000);
50         },
51         beforeSend: function(data){
52           msg.removeClass('error');
53           msg.html(' (loading...)');
54         }
55       });
56     }
57   }