René's URL Explorer Experiment


Title: 【JavaScript】【学习心得】学习 JavaScript 第十一天 · Issue #15 · paddingme/Learning-JavaScript · GitHub

Open Graph Title: 【JavaScript】【学习心得】学习 JavaScript 第十一天 · Issue #15 · paddingme/Learning-JavaScript

X Title: 【JavaScript】【学习心得】学习 JavaScript 第十一天 · Issue #15 · paddingme/Learning-JavaScript

Description: Ajax Ajax 是什么 Ajax 全称为 Asynchronous JavaScript and XML(异步 JavaScript 和 XML),是一种创建交互式网页应用的网页开发技术。简单点说就是以往Web 应用涉及大量的页面刷新:用户点击某个链接,请求发送回服务器,然后服务器根据用户的操作再返回新页面。尽管是网页页面一小部分的变化,也会刷新页面和重新加载整个页面,诸如页面logo,导航,footer 区域等。而使用 Ajax 就可以做到只更新页面中的一小部分,...

Open Graph Description: Ajax Ajax 是什么 Ajax 全称为 Asynchronous JavaScript and XML(异步 JavaScript 和 XML),是一种创建交互式网页应用的网页开发技术。简单点说就是以往Web 应用涉及大量的页面刷新:用户点击某个链接,请求发送回服务器,然后服务器根据用户的操作再返回新页面。尽管是网页页面一小部分的变化,也会刷新页面和重新加载整个页面,诸如页面logo,...

X Description: Ajax Ajax 是什么 Ajax 全称为 Asynchronous JavaScript and XML(异步 JavaScript 和 XML),是一种创建交互式网页应用的网页开发技术。简单点说就是以往Web 应用涉及大量的页面刷新:用户点击某个链接,请求发送回服务器,然后服务器根据用户的操作再返回新页面。尽管是网页页面一小部分的变化,也会刷新页面和重新加载整个页面,诸如页面logo,...

Opengraph URL: https://github.com/paddingme/Learning-JavaScript/issues/15

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"【JavaScript】【学习心得】学习 JavaScript 第十一天","articleBody":"## Ajax\n### Ajax 是什么\n\nAjax 全称为 Asynchronous JavaScript and XML(异步 JavaScript 和 XML),是一种创建交互式网页应用的网页开发技术。简单点说就是以往Web 应用涉及大量的页面刷新:用户点击某个链接,请求发送回服务器,然后服务器根据用户的操作再返回新页面。尽管是网页页面一小部分的变化,也会刷新页面和重新加载整个页面,诸如页面logo,导航,footer 区域等。而使用 Ajax 就可以做到只更新页面中的一小部分,而不用刷新整个页面。\n### Ajax 原理\n\nAjax 的原理简单来说通过 XmlHttpRequest 对象来向服务器发**异步请求**,从服务器获得数据,然后用 JavaScript来操作 DOM 而更新页面。这其中最关键的一步就是从服务器获得请求数据。\n以往我们浏览网页的原理是由 Client 向 Server 提交页面申请,再由 Server 将申请通过 HTTP 传回给 Client 生成浏览页面:\n\n![Ajax 原理图](http://yianbin.qiniudn.com/fe-ajax-a.png)\n\n使用 Ajax 后的工作原理如下图,可见通过 Ajax 在用户交互方面有了很大改进,用户可以不用为提交了 Form 而长时间等待服务器应答,而且通过 Ajax 也可以开发出华丽的 Web 交互页面。\n\n![Ajax 原理图](http://yianbin.qiniudn.com/fe-ajax-b.png)\n\nAjax 的适用范围:它依赖 JavaScript,有可能有浏览器不支持,另搜索引擎的蜘蛛程序也不会抓取相关内容。\n### XMLHttpRequest\n\nAjax 技术的核心是 XMLHttpRequest 对象,它充当着浏览器中的脚本(客户端)与服务器之间的中间人的角色。\n\n由于XXX 的 IE 浏览器 实现的 XMLHttp 方式不一样,我们有必要再一次来兼容下。\n\n``` js\nfunction getHTTPObject() {\n  if (typeof XMLHttpRequest == \"undefined\") {\n    XMLHttpRequest = function() {\n      try { return new ActiveXObject(\"Msxml2.XMLHTTP.6.0\");}\n        catch (e) {}\n      try { return new ActiveXObject(\"Msxml2.XMLHTTP.3.0\");}\n        catch (e) {}\n      try { return new ActiveXObject(\"Msxml2.XMLHTTP\");}\n        catch (e) {}\n      return false;\n    }\n  }\n  return new XMLHttpRequest();\n}\n```\n\n为了模拟 Ajax 服务器请求,我们首先建立一个 HTML 页面\n\n``` html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"zh-cmn-Hans\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003ctitle\u003eAjax DEMO\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cdiv id=\"new\"\u003e\u003c/div\u003e\n\u003cscript src=\"addLoadEvent.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"1-7-2.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\n```\n\n命名为 1-7-2.html,在同级文件夹下建立一个1-7-2.txt里随便输入一些内容。\n\nXMLHttpRequest 对象常用方法为 open 方法,它用来指定服务器上将要访问的文件,指定请求类型:GET、POST 或 SEND。这个方法第三个参数用于指定请求是否以异步方式发送和处理。\n\n``` js\nfunction getHTTPObject() {\n  if (typeof XMLHttpRequest == \"undefined\") {\n    XMLHttpRequest = function() {\n      try { return new ActiveXObject(\"Msxml2.XMLHTTP.6.0\");}\n        catch (e) {}\n      try { return new ActiveXObject(\"Msxml2.XMLHTTP.3.0\");}\n        catch (e) {}\n      try { return new ActiveXObject(\"Msxml2.XMLHTTP\");}\n        catch (e) {}\n      return false;\n    }\n  }\n  return new XMLHttpRequest();\n}\n\nfunction getNewContent() {\n  var request = new getHTTPObject();\n  if (request) {\n    request.open(\"GET\",\"1-7-2.text\",true);\n    request.onreadystatechange = function() {\n      if (request.readyState == 4) {\n        var para = document.createElement(\"p\");\n        var txt = document.createTextNode(request.responseText);\n        para.appendChild(txt);\n        document.getElementById(\"new\").appendChild(para);\n      }\n    };\n    request.send(null);\n  } else {\n    alert (\"对不起,您的浏览器不支持 XMLHttpRequest!\");\n  }\n}\n\naddLoadEvent(getNewContent);\n```\n\n浏览器加载 HTML 页面 没有反应,为什么呢。把它放在tomcat webapp 目录下 启动你的tomcat 然后再试试。Ajax 需要向服务器发起请求,而不是单纯的像我们之前用浏览器打开一个静态的 HTML 页面\n如图所示:是不是很帅气的出现了。\n\n![tomcat webapp 文件目录](http://paddingme.qiniudn.com/ajax.PNG)\n![页面 demo](http://paddingme.qiniudn.com/demo.PNG)\n\n其中上述的 onreadystatechange 是一个事件处理函数。它会在服务器给 XMLHttpRequest 对象送回响应时的时候被触发执行。\n\n``` js\nrequest.onreadystatechange = function() {\n    //处理响应\n}\n```\n\n在你 onreadystatechange 指定函数引用是,不要在函数名后加括号(表示立即调用),我们的目的是指向把函数自身的引用(而不是函数结果)赋值给 onreadystatechange 属性。\n\n```\nrequest.onreadystatechange = dosomething;\n```\n\n在指定了请求的目标之后,也明确了如何处理响应之后,用 send 方法发送请求。\n\n``` js\nrequest.send(null);\n```\n\n如果 浏览器不支持 XMLHttpRequest 对象 还需要做处理。\n\n服务器在向 XMLHttpRequest 对象返回响应时,该对象有许多属性可用,浏览器会在不同阶段更新 readystate 属性的值:\n- 0 表示未初始化\n- 1 表示正在加载\n- 2 表示加载完毕\n- 3 表示正在交互\n- 4 表示完成(此时,可以访问服务器发回来的数据了)\n\n访问服务器发回来的数据有两个属性:\n- responseText 属性:用于保存文本字符串形式的数据;\n- responseXML 属性:用于保存 Content-Type 头部中指定为 “text/xml” 的数据,其实为一个 DocumentFragment 对象, 可用各种 DOM 方法来处理此对象。\n\n在使用 Ajax 一定要注意 **同源策略**。 使用 XMLHttpRequest 对象发送的请求只能访问与其所在的 HTML 处于同一个域中的数据,不能向其他域发送请求。\n\n注意 Ajax 是异步请求,异步请求很容易忽略其异步性——脚本的执行不会等 send 的响应,而是会继续执行。\n### 渐进增强的使用 Ajax\n\n**Ajax 应用主要依赖于服务器端处理,而非客户端处理**,实际上是服务器端的脚本完成了绝大部分工作。XMLHttpRequest 对象作为浏览器与服务器之间的“中间人”,它只是负责传递和响应。如果把它拿掉,浏览器与服务器之间的请求和响应应该继续完成,只不过需要的时间可能会长点。\n构建 Ajax 网站的最好方法是先构建一个常规的网站,然后渐进增强的使用 Ajax(Hijax)。\n\np.s.:其中部分内容引自:[AJAX 的工作原理](https://github.com/infp/Front-end-Interview/blob/master/source/javascript.md#21%E8%AF%B7%E5%B0%BD%E5%8F%AF%E8%83%BD%E8%AF%A6%E5%B0%BD%E7%9A%84%E8%A7%A3%E9%87%8A-ajax-%E7%9A%84%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86)\n","author":{"url":"https://github.com/paddingme","@type":"Person","name":"paddingme"},"datePublished":"2014-11-27T14:07:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/15/Learning-JavaScript/issues/15"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:61c7a6ac-575e-c8ec-7b43-d2bc4b9dc646
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8706:A2614:304E6D3:45FEE23:6A60F007
html-safe-nonced4c561036e20306b607667365c0056b7f5312ac33127c02eee99bdebeecee70d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzA2OkEyNjE0OjMwNEU2RDM6NDVGRUUyMzo2QTYwRjAwNyIsInZpc2l0b3JfaWQiOiI2MjQ3NzQ0OTcyODU3MDc3NzY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac2b2bf866014e8bc3d26a1f206cdc133c987ffd855921c242eaa04e466ccd0f18
hovercard-subject-tagissue:50294883
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/paddingme/Learning-JavaScript/15/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ec04742b83089dc697fe34ba5db97b610a97eff457b3aa26efd919e68225733f/paddingme/Learning-JavaScript/issues/15
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ec04742b83089dc697fe34ba5db97b610a97eff457b3aa26efd919e68225733f/paddingme/Learning-JavaScript/issues/15
og:image:altAjax Ajax 是什么 Ajax 全称为 Asynchronous JavaScript and XML(异步 JavaScript 和 XML),是一种创建交互式网页应用的网页开发技术。简单点说就是以往Web 应用涉及大量的页面刷新:用户点击某个链接,请求发送回服务器,然后服务器根据用户的操作再返回新页面。尽管是网页页面一小部分的变化,也会刷新页面和重新加载整个页面,诸如页面logo,...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepaddingme
hostnamegithub.com
expected-hostnamegithub.com
None3ba36a464b9464992131f4003292a219fc87f92404b0dbe3fd1ef07f11102d0f
turbo-cache-controlno-preview
go-importgithub.com/paddingme/Learning-JavaScript git https://github.com/paddingme/Learning-JavaScript.git
octolytics-dimension-user_id5771087
octolytics-dimension-user_loginpaddingme
octolytics-dimension-repository_id25473884
octolytics-dimension-repository_nwopaddingme/Learning-JavaScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id25473884
octolytics-dimension-repository_network_root_nwopaddingme/Learning-JavaScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2cc5e4f897a27632dd600edfec4c737bea2f8338
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/paddingme/Learning-JavaScript/issues/15#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpaddingme%2FLearning-JavaScript%2Fissues%2F15
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpaddingme%2FLearning-JavaScript%2Fissues%2F15
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=paddingme%2FLearning-JavaScript
Reloadhttps://github.com/paddingme/Learning-JavaScript/issues/15
Reloadhttps://github.com/paddingme/Learning-JavaScript/issues/15
Reloadhttps://github.com/paddingme/Learning-JavaScript/issues/15
paddingme https://github.com/paddingme
Learning-JavaScripthttps://github.com/paddingme/Learning-JavaScript
Notifications https://github.com/login?return_to=%2Fpaddingme%2FLearning-JavaScript
Fork 13 https://github.com/login?return_to=%2Fpaddingme%2FLearning-JavaScript
Star 28 https://github.com/login?return_to=%2Fpaddingme%2FLearning-JavaScript
Code https://github.com/paddingme/Learning-JavaScript
Issues 30 https://github.com/paddingme/Learning-JavaScript/issues
Pull requests 0 https://github.com/paddingme/Learning-JavaScript/pulls
Actions https://github.com/paddingme/Learning-JavaScript/actions
Projects https://github.com/paddingme/Learning-JavaScript/projects
Wiki https://github.com/paddingme/Learning-JavaScript/wiki
Security and quality 0 https://github.com/paddingme/Learning-JavaScript/security
Insights https://github.com/paddingme/Learning-JavaScript/pulse
Code https://github.com/paddingme/Learning-JavaScript
Issues https://github.com/paddingme/Learning-JavaScript/issues
Pull requests https://github.com/paddingme/Learning-JavaScript/pulls
Actions https://github.com/paddingme/Learning-JavaScript/actions
Projects https://github.com/paddingme/Learning-JavaScript/projects
Wiki https://github.com/paddingme/Learning-JavaScript/wiki
Security and quality https://github.com/paddingme/Learning-JavaScript/security
Insights https://github.com/paddingme/Learning-JavaScript/pulse
【JavaScript】【学习心得】学习 JavaScript 第十一天https://github.com/paddingme/Learning-JavaScript/issues/15#top
Mu-Help-Planhttps://github.com/paddingme/Learning-JavaScript/issues?q=state%3Aopen%20label%3A%22Mu-Help-Plan%22
https://github.com/paddingme
paddingmehttps://github.com/paddingme
on Nov 27, 2014https://github.com/paddingme/Learning-JavaScript/issues/15#issue-50294883
https://camo.githubusercontent.com/9995bd5645b8c2d3392f29c4678758e95e7a8473792f5c388ba0a037ef36b4a4/687474703a2f2f7969616e62696e2e71696e6975646e2e636f6d2f66652d616a61782d612e706e67
https://camo.githubusercontent.com/b9a80e4248ce77b3819db7437ee4b0f804694e455b9d74222cd29f8952dfbd37/687474703a2f2f7969616e62696e2e71696e6975646e2e636f6d2f66652d616a61782d622e706e67
https://camo.githubusercontent.com/f64cd83ac3a320b500e61d193c160cd3719681dd51d2f4f1c7185c23972f0dc8/687474703a2f2f70616464696e676d652e71696e6975646e2e636f6d2f616a61782e504e47
https://camo.githubusercontent.com/be9b2ac3fb2e543770c095e50187fad27f1bd91b4ae3d2b3151b875b26917965/687474703a2f2f70616464696e676d652e71696e6975646e2e636f6d2f64656d6f2e504e47
AJAX 的工作原理https://github.com/infp/Front-end-Interview/blob/master/source/javascript.md#21%E8%AF%B7%E5%B0%BD%E5%8F%AF%E8%83%BD%E8%AF%A6%E5%B0%BD%E7%9A%84%E8%A7%A3%E9%87%8A-ajax-%E7%9A%84%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86
Mu-Help-Planhttps://github.com/paddingme/Learning-JavaScript/issues?q=state%3Aopen%20label%3A%22Mu-Help-Plan%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.