I used the Post method to send a user name and password to the server side, want to use PHP to implement the server response to the behavior, return a successful login string, how to do it? And how does the client get the string?
Reply to discussion (solution)
To see W3school.
Write a demo, enter the username=fdipzone,password=123456 server back to return success, or return failure.
client.html
Client Post Username
Password
server.php
Ajax? Let's talk about how you post to the server.
In order to realize that the client sends the data to the server, the server responds to the data to the client, and finally the client sends the result of the response data to the server side.
The total is the tri-rounds data exchange process, how to achieve this?
Three processes want to be able to achieve the entire process by clicking the login button once.
You just press a button, call a method, and then callback other methods inside the method. Until the process is finished.
Can write like this.
function Fsubmit () {
$.post ("server.php", {username: $ ("#username"). Val (), Password: $ ("#password"). Val ()},function (ret) {
if (ret.success==true) {
Log in successfully, the second method can be called here
Dosecondfunc ();
}else{
Alert (' login fail ');
}
}, ' json ');
}
function Dosecondfunc () {
Do STH
If there is, you can call thrid function here again
}
Can I add parameters to the address, such as "Server.php?a=1"?
Can I add parameters to the address, such as "Server.php?a=1"?
Yes, but a needs to use $_get[' a '] to get
$array = Array ( ' get ' = = $_get[' gettest '], ' post ' = ' $_post[' test '); Echo Json_encode ($array);
After an afternoon, I finally figured it out, thank you.