AJAX wrapper class usage guide
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!
<html> <head> <title>Ajax实例</title> <script src="ajax3.0.js"></script> </head> <body> <script> document.write(new Date()+"<br>"); document.write(new Date()+"<br>"); document.write(new Date()+"<br>"); </script> <p id="show" style="background:yellow;border:1px solid blue"> 内容加载中..... </p> <script> function read() { Ajax().get("read.php?num="+Math.random(), function(data){ document.getElementById("show").innerHTML=data; }) } read(); setInerval("read()",3000); function send() { var username=document.frm.username; var desn=document.frm.desn; var datao = {username:username.value, desn:desn.value}; Ajax().post("save.php", datao, function(data){ read(); username.value=""; desn.value=""; }); } </script> <form name="frm"> 用户名:<input type="text" name="username" value=""><br> 内容: <textarea cols="40" rows="5" name="desn"></textarea> <input type="button" onclick="send()" value="留言"> </form> <script> document.write(new Date()+"<br>"); document.write(new Date()+"<br>"); document.write(new Date()+"<br>"); </script> </body> </html>
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."<br>"; fwrite($fh, $text); fclose($fh); //demo.text fdsafdsa--2012-11-01 12:24:04说:fdsafdsa<br>fdsafdsa--2012-11-01 12:24:07说:fdsafdsafsa<br>111--2012-11-01 12:25:07说:2222<br>eeee--2012-11-01 12:25:10说:eeee<br>fdsfds--2012-11-01 12:25:12说:fdsfdsfds<br>fdsfds--2012-11-01 12:25:19说:fdsfdsfs<br>fdsfdsf--2012-11-01 12:25:22说:sfdsfdsfds<br>fdsafdsa--2012-11-01 12:26:00说:fdsafdsa<br>
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.

Title: Methods and code examples to resolve 403 errors in jQuery AJAX requests. The 403 error refers to a request that the server prohibits access to a resource. This error usually occurs because the request lacks permissions or is rejected by the server. When making jQueryAJAX requests, you sometimes encounter this situation. This article will introduce how to solve this problem and provide code examples. Solution: Check permissions: First ensure that the requested URL address is correct and verify that you have sufficient permissions to access the resource.

jQuery is a popular JavaScript library used to simplify client-side development. AJAX is a technology that sends asynchronous requests and interacts with the server without reloading the entire web page. However, when using jQuery to make AJAX requests, you sometimes encounter 403 errors. 403 errors are usually server-denied access errors, possibly due to security policy or permission issues. In this article, we will discuss how to resolve jQueryAJAX request encountering 403 error

According to news from this site on April 17, TrendForce recently released a report, believing that demand for Nvidia's new Blackwell platform products is bullish, and is expected to drive TSMC's total CoWoS packaging production capacity to increase by more than 150% in 2024. NVIDIA Blackwell's new platform products include B-series GPUs and GB200 accelerator cards integrating NVIDIA's own GraceArm CPU. TrendForce confirms that the supply chain is currently very optimistic about GB200. It is estimated that shipments in 2025 are expected to exceed one million units, accounting for 40-50% of Nvidia's high-end GPUs. Nvidia plans to deliver products such as GB200 and B100 in the second half of the year, but upstream wafer packaging must further adopt more complex products.

How to solve the problem of jQueryAJAX error 403? When developing web applications, jQuery is often used to send asynchronous requests. However, sometimes you may encounter error code 403 when using jQueryAJAX, indicating that access is forbidden by the server. This is usually caused by server-side security settings, but there are ways to work around it. This article will introduce how to solve the problem of jQueryAJAX error 403 and provide specific code examples. 1. to make

Using Ajax to obtain variables from PHP methods is a common scenario in web development. Through Ajax, the page can be dynamically obtained without refreshing the data. In this article, we will introduce how to use Ajax to get variables from PHP methods, and provide specific code examples. First, we need to write a PHP file to handle the Ajax request and return the required variables. Here is sample code for a simple PHP file getData.php:

Guidelines and tips for using macros in Golang programming. In Golang programming, macros are a very powerful tool that can help us simplify the code and improve the readability and maintainability of the program. Although Golang (Go language) itself does not directly support macros, we can achieve macro-like functions by using code generation tools or custom functions. This article will introduce in detail the usage guidelines and some techniques of macros in Golang programming, and provide specific code examples. What is Macro Macro is a

This website reported on July 9 that the AMD Zen5 architecture "Strix" series processors will have two packaging solutions. The smaller StrixPoint will use the FP8 package, while the StrixHalo will use the FP11 package. Source: videocardz source @Olrak29_ The latest revelation is that StrixHalo’s FP11 package size is 37.5mm*45mm (1687 square millimeters), which is the same as the LGA-1700 package size of Intel’s AlderLake and RaptorLake CPUs. AMD’s latest Phoenix APU uses an FP8 packaging solution with a size of 25*40mm, which means that StrixHalo’s F
