js request php does not jump

angryTom
Release: 2023-02-27 09:02:01
Original
3121 people have browsed it

js request php does not jump

#js can use AJAX technology to request php without jumping.

What is AJAX?

Ajax stands for "Asynchronous Javascript And XML" (asynchronous JavaScript and XML), which refers to a web development technology for creating interactive web applications.

Ajax is a technology for creating fast, dynamic web pages that can update parts of a web page without reloading the entire web page.

Ajax allows web pages to be updated asynchronously by exchanging a small amount of data with the server in the background. This means that parts of a web page can be updated without reloading the entire page.

js request php example:

<input type="text" id="textarea1">
<button id="sub">提交</button>

// 引入jQuery.js库文件,jQuery为我们封装好了ajax请求的方法,不需要自己写
<script type="text/javascript" src="jquery.js"></script>
<script>
	$(document).ready(function(){
		$(&#39;#sub&#39;).click(function(){
			var val=$(&#39;textarea1&#39;).val();
			$.post(&#39;savexml.php&#39;,{"val":val},function(data){
				json = eval("(" + data + ")");
				if(json.status==1){//提交ajax请求成功
				//处理
				}else{//失败
				//处理
			}
		});
		},&#39;json&#39;);
	});
</script>
Copy after login

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of js request php does not jump. 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