知识点20:AJAX

And by specifically when I say updating a page's content, I'm not saying we rewrite the page using JavaScript. I'm saying we actually request more information from the server without our page having to reload.

Now, it's very easy to do this. We just say var, whatever we want to call this object, equals new XMLHttpRequest.

And now we have now obtained an AJAX sort of object, or an XMLHttpRequest object, which will allow us to asynchronously update our page.

After we have gotten this new object, this XMLHttpRequest, we have to do something to its onreadystatechange behavior.

Onreadystatechange behavior is really just when you make a request to a web page, the page goes through a number of steps.

First, a request hasn't been sent.

Then, the request has been sent, but not acted upon.

Then the request has been acted upon.

Then the request is being sent back to you.

Then, the request is fully loaded in your page.

Those are different states.

So what does this maybe look like in context?

So here's a function that deals with AJAX requests.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容