Skip to Main Content
Wydajny JavaScript.
book

Wydajny JavaScript.

by Nicholas C. Zakas
September 2016
Intermediate to advanced content levelIntermediate to advanced
224 pages
7h 33m
Polish
APN Promise
Content preview from Wydajny JavaScript.
Skrypty nieblokujące | 11
wstrzyknięcie nastronę kodu JavaScript przy użyciu dynamicznego elementu
<script>
.
Oto prosty przykład:
var xhr = new XMLHttpRequest();
xhr.open("get", "file1.js", true);
xhr.onreadystatechange = function(){
if (xhr.readyState == 4){
if (xhr.status >= 200 && xhr.status < 300 || xhr.status == 304){
var script = document.createElement("script");
script.type = "text/javascript";
script.text = xhr.responseText;
document.body.appendChild(script);
}
}
};
xhr.send(null);
Kod ten wysyła żądanie
GET
poplik le1.js. Obsługa zdarzenia
onreadystatechange
spraw-
dza, czy stan
readyState
jest równy 4, anastępnie sprawdza ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Wszechstronny JavaScript

Wszechstronny JavaScript

Adam D. Scott
Programowanie w JavaScript Rusz głową!

Programowanie w JavaScript Rusz głową!

Eric Freeman, Elisabeth Robson

Publisher Resources

ISBN: 9788375413113