Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ajax tutorial on how to get the contents of site files

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the "Ajax get site file content method tutorial" knowledge, in the actual case of the operation process, many people will encounter such a dilemma, then let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

A simple Ajax example: Select a book and get the relevant names in real time via Ajax.

Put four html files under the same file on your web site.

index.html

The copy code is as follows:

A simple Ajax instance that doesn't involve servers

//declare a variable that references XMLHttpRequest

var xhr = null;

//Select a function to call when writing

function updateCharacters() {

var selectShow = document.getElementById("selShow").value;

if (selectShow == "") {

document.getElementById("divCharacters")[xss_clean] = "";

return ;

}

//instantiate an XMLHttpRequest object

if (window.XMLHttpRequest) {

//Non-IE

xhr = new XMLHttpRequest();

} else {

// IE

xhr = new ActiveXObject("Microsoft.XMLHTTP");

}

xhr.onreadystatechange = callbackHandler;

url = selectShow + ".html";

xhr.open("post", url, true);

xhr.send(null);

}

// this is the function that will repeatedly be called by our

// XMLHttpRequest object during the life cycle of request

function callbackHandler() {

if (xhr.readyState == 4) {

document.getElementById("divCharacters")[xss_clean] = xhr.responseText;

}

}

Our first Ajax instance

Choose a book:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report