简体   繁体   中英

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?

Read the XHR documentation here.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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