简体   繁体   English

XMLHttpRequest对象

[英]The XMLHttpRequest object

I have a few questions about XMLHttpRequest. 我对XMLHttpRequest有一些疑问。

  1. Is it true that this is not a Javascript object, but an object that is native to the browser? 确实这不是Javascript对象,而是浏览器本地的对象吗? This is the first time I have heard of a browser having "native objects." 这是我第一次听说具有“本机对象”的浏览器。 What other native objects does a browser have? 浏览器还具有其他哪些本机对象?

  2. It seems that XMLHttpRequest existed before Ajax. 似乎XMLHttpRequest在Ajax之前存在。 If that is true, then what was it used for? 如果这是真的,那它是做什么用的?

  3. It has 5 attributes: readyState, status, onreadystatechange, responseText, responsXml. 它具有5个属性:readyState,status,onreadystatechange,responseText,responsXml。 Notice that these are all written in lower camel case, except for onreadystatechange. 请注意,除了onreadystatechange以外,所有这些均以小写驼峰书写。 Why is that? 这是为什么?

XMLHttpRequest first originated by IE, it was later also included in most other browsers including Firefox. XMLHttpRequest首先由IE发起,后来也被包括在Firefox在内的大多数其他浏览器中。

Back then, Microsoft had its own use of the XMLHttpRequest object. 那时,Microsoft有自己的XMLHttpRequest对象用法。

It was only sometime in 2005 that the XMLHttpRequest object became "discovered", widely known and useful to be able to post data asynchronously to the server without holding user's browser. 直到2005年的某个时候, XMLHttpRequest对象才被“发现”,广为人知且有用,它能够在不持有用户浏览器的情况下将数据异步发布到服务器。

The name AJAX was coined using XMLHttpRequest . 名称AJAX是使用XMLHttpRequest创造的。

XMLHttpRequest is an enabler of AJAX, which is a combination of this object + XML + JS (Although these days you could arguably say JSON serves the job better than XML) XMLHttpRequest是AJAX的使能器,它是此对象+ XML + JS的组合(尽管如今,您可以说JSON比XML更好地完成了这项工作)

  1. Actually most of the build-in objects/types are native objects/types because of performance reasons, and some of them are native feature related so they have to be native objects/types. 实际上,由于性能原因,大多数内置对象/类型都是本机对象/类型,其中一些是与本机功能相关的,因此它们必须是本机对象/类型。 They just have JavaScript wrappers and can be accessed by JavaScript. 它们仅具有JavaScript包装器,并且可以被JavaScript访问。

  2. XMLHttpRequest is the base of AJAX, AJAX is a buzz word raised by XHR and finally became a concept like "dynamic, fancy, user friendly client-side webpage". XMLHttpRequest是AJAX的基础,AJAX是XHR提出的流行语,最终成为了诸如“动态,精美,用户友好的客户端网页”之类的概念。

  3. That's the naming convention of "event", like "onclick", "onmouseover". 这就是“事件”的命名约定,例如“ onclick”,“ onmouseover”。 The camel case is for methods. 骆驼案是针对方法的。 The type convertion for types/classes is pascal case, eg, "XMLHttpRequest". 类型/类的类型转换是pascal的情况,例如“ XMLHttpRequest”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM