Retired, retired-AJAX, retired, retired-AJAX
hi
Last night, I unfortunately got a sprained foot while playing basketball.
You know, the last time I sprained my foot was four years ago; the injury was to my left foot. It was also the most serious injury to my sprained foot in so many years of playing basketball. After resting for a whole month, I was able to come back under the meticulous care of my brothers in the dormitory, and finally bought a noble ankle brace.
Later, when I played ball again, I usually wore an ankle brace on my left foot, and the usual small splint had basically no effect. Four years have passed, and last night was the end of the good times. Unfortunately, this time the injury was to the right foot, and the condition was just as serious.
However, after being injured, I also have my own time to think about things that I usually have no time to touch in my impatience. It's a blessing and a curse, you can't stop learning PHP.
1, AJAX
2. AJAXConcept introduction
2.2 XMLHttpRequestObject Creation
The abbreviation ofis XHR.
The first thing is to instantiate the XHR object.
var request=new XMLHttpRequest();
Versions before IE6 are not supported, but others are ok.
2.3 HttpRequest
is a rule for computers to communicate over a network.
is a stateless protocol - does not establish a persistent connection. (No memory)
Steps: TCP connection, request, response, send data, close connection.
--Request
Basic format: method and action (GET or POST) URL header (verification information) body
GET: Generally used to obtain information , using URL to pass parameters (so characters are limited), is the default Http method; generally safe - because GET only obtains information, which is equivalent to querying, and does not change the data; but GET is visible to everyone.
POST: Generally used to modify resources on the server (such as sending form data); is not visible to others , does not use URL, and is useful for sending Unlimited quantity.
GET is idempotent (no matter how many times the operation is performed, it will not make a difference).
--Response
Basic format: status code (numbers and text) response header response body
-Status code : starts with three digits, where the first digit defines the type of status code :
1xx indicates information type and is being processed;
2xx means success;
3xx indicates redirection and the request was unsuccessful;
4xx, indicating a client error. The request submitted by the client is incorrect, such as 404 not found, indicating that the document referenced in the request does not exist;
5xx, indicating a server error, which is a very troublesome situation, such as 500.
2.4 XHRSend request
Two useful methods.
Establish a connection: request.open(method, url, async) - method: GET and POST, url address, synchronous or asynchronous (async is true)
Send a request: request.send(string) - each connection should be open, so the send here does not need to write a method, url
2.5 XHR Get/Get Response
Use the following methods or attributes to obtain corresponding data:
responseText: Get response data in string form
responseXML: XML form
status and statusText: Return the HTTP status code in numeric and text form
getAllResponseHeader(): Get all response headers
getResponseHeader(): Query the value of a field in the response
Determine whether to respond
readyState attribute - 01234, to 4 means the response is completed. Use the following program to monitor and judge.
request.onreadystatechange=function(){
if(request.readyState===4&&request.status===200){
request.responseText
}
}
--General steps
new XHR object open method send data to monitor the process.
3. A simple example of AJAX
3.1 Introduction
Complete: Query employee information, query the employee's basic information by entering the employee number. Create new employee information, including employee name, number, gender, position;
Implementation: pure html page PHP page, used to implement the backend interface for querying employees and creating new employees;
3.2 Server-side implementation
I am using the wamp collection end here, so many things do not need to be changed.
Then write the program in dreamwaver
-------------------------
Hey, my will is still not strong enough. . . I won’t write today, I have to finish this tomorrow and worry about the rest!

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Using preprocessing statements and PDO in PHP can effectively prevent SQL injection attacks. 1) Use PDO to connect to the database and set the error mode. 2) Create preprocessing statements through the prepare method and pass data using placeholders and execute methods. 3) Process query results and ensure the security and performance of the code.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP makes it easy to create interactive web content. 1) Dynamically generate content by embedding HTML and display it in real time based on user input or database data. 2) Process form submission and generate dynamic output to ensure that htmlspecialchars is used to prevent XSS. 3) Use MySQL to create a user registration system, and use password_hash and preprocessing statements to enhance security. Mastering these techniques will improve the efficiency of web development.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1
Powerful PHP integrated development environment