This article mainly introduces the guide to the use of AJAX encapsulation classes. Friends who need it can refer to it.
AJAX feels difficult to talk about, but if you encapsulate it, you will find that it is very simple to use, of course. Simple applications, such as message board applications, etc. First of all, let me give you a gift, which is a packaged AJAX class. The download address is http://xiazai.jb51.net/201412/yuanma/ajax3.0(jb51 .net).rar Download this class here and teach you how to use it!
Example!
First add our ajax3.0.js file, and then we will write this Ajax().post("save.php", datao, function(data))
ajax( ) The first of the two parameters returns xml json or html. The second one is true for asynchronous transmission and false for synchronous transmission. You will understand after the post.
The bottom is the php file
//read.php @readfile("demo.txt"); //save.php // header("Content-Type:text/html;charset=gb2312") $username=$_POST["username"]; $desn = $_POST["desn"]; $fh = fopen("demo.txt", "a"); $text=$username."--".date("Y-m-d H:i:s")."说:".$desn."
"; fwrite($fh, $text); fclose($fh); //demo.text fdsafdsa--2012-11-01 12:24:04说:fdsafdsa
fdsafdsa--2012-11-01 12:24:07说:fdsafdsafsa
111--2012-11-01 12:25:07说:2222
eeee--2012-11-01 12:25:10说:eeee
fdsfds--2012-11-01 12:25:12说:fdsfdsfds
fdsfds--2012-11-01 12:25:19说:fdsfdsfs
fdsfdsf--2012-11-01 12:25:22说:sfdsfdsfds
fdsafdsa--2012-11-01 12:26:00说:fdsafdsa
The above is what I compiled for everyone. Yes, I hope it will be helpful to everyone in the future.
Related articles:
How to solve the 403 error when django uses ajax post data
A brief analysis of IE’s caching problem for Ajax request results
A detailed explanation of the use of various AJAX methods
The above is the detailed content of AJAX wrapper class usage guide. For more information, please follow other related articles on the PHP Chinese website!