简体   繁体   English

AJAX请求仅加载/打开特定的div,而不使用JQuery?

[英]AJAX request to only load/open a specific div without using JQuery?

Im looking to do something like this 我希望做这样的事情

$('#thisdiv').load(document.URL + ' #thisdiv');

where only the elements with the specified selector are loaded from the server, but I can't use Jquery, anyone know how to do it? 从服务器中仅加载具有指定选择器的元素,但是我无法使用Jquery,有人知道该怎么做吗?

Read the XHR documentation here. 在这里阅读XHR文档。

Basically, you create an XMLHttpRequest object (be wary of older browsers), then trigger its methods to load some content, then take the response and copy it where you want it. 基本上,您创建一个XMLHttpRequest对象(对较旧的浏览器保持警惕),然后触发其方法以加载某些内容,然后获取响应并将其复制到所需的位置。

The link above goes on to discuss XML parsing, which may come in handy if you want to use just the "#thisdiv" part of the XHR response. 上面的链接继续讨论XML解析,如果您只想使用XHR响应的“ #thisdiv”部分,它可能会派上用场。

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

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