Home > Web Front-end > Front-end Q&A > How to interact between the front and back ends of the Web

How to interact between the front and back ends of the Web

Guanhui
Release: 2020-05-30 14:05:51
Original
4629 people have browsed it

How to interact between the front and back ends of the Web

How Web front-end and back-end interact

Use AJAX to perform asynchronous data requests. AJAX refers to a method for creating interactive and fast dynamic web applications. Web development technology that can update parts of web pages without reloading the entire web page.

Code example

if (window.XMLHttpRequest) {
	//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
	xmlhttp = new XMLHttpRequest();
} else {
	// IE6, IE5 浏览器执行代码
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange = function(){
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
	{
		alert(xmlhttp.responseText);
	}
}
xmlhttp.open("GET", "./get_user.php", true);
xmlhttp.send();
Copy after login

jQuery example

$.ajax({
	type: 'POST'
	url: './get_user.php',
	data: {uid: 123},
	dataType: 'json',
	success: function(result){
        console.log(result);
	}
});
Copy after login

Recommended tutorial: "JS Tutorial

The above is the detailed content of How to interact between the front and back ends of the Web. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template