I am a front-end soon after getting started. Besides HTML and CSS, I know more about JS and JQ. How can I write the backend to connect the data? Usually, I just need to restore the page like the design draft. I am a front-end soon after getting started. Besides HTML and CSS, I know more about JS and JQ. How can I write the backend to connect the data?
Usually, I just need to restore the page like the design draft.
Reply content:
I am a front-end soon after getting started. Besides HTML and CSS, I know more about JS and JQ. How can I write the backend to connect the data?
Usually, I just need to restore the page like the design draft.
RESTFUL API
I feel that ajax is used to asynchronously load data.
Some js interactions on my side may need to be completed by the server, and the results of the complex points will be done by the front-end.
Directly to the front-end interface, the request path can be connected. Not as hard as imagined
Front end $. get ("test. php", {name: "John "});
Backend _ GET ['name']
Front end $. post ("test. php", {name: "John "});
Backend _ POST ['name']
Json is used for data exchange format, and the backend provides you with corresponding interfaces. parameter descriptions are very convenient.
Php School
You can use the native xmlhttprequest object to send a get request and a post request to complete interaction. For jQ, you can use the $ get and $ post methods, but I feel that $ ajax is more useful.
Let's take a look at ajax and learn about js very quickly.
Data is provided in the background. You can call the data interface directly...
In front-end
If Javascript is used for ajax cross-origin, jsonp is used.
If jq is used and $. ajax is used for cross-origin, $. ajax is also used. However, if you need to change the content, Baidu
The general process is that the project manager provides api documents, such as swagger oai documents, and then establishes a front-end model based on the documents. With the help of mock, the local interface is called and submitted and merged to the background. The interface document describes the method of connection. This document can be implemented only after it is determined. The above several parameters indicate that jQuery Ajax is only implemented.
Understanding http is the first step
Interface. The API is the same as the function we usually use. When you pass parameters, the data can be passed to the backend, and whether a return value is required depends on whether your business logic needs to return data.