Home  >  Article  >  Web Front-end  >  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
GuanhuiOriginal
2020-05-30 14:05:514580browse

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();

jQuery example

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

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!

Statement:
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