Separating the front and rear end with jQuery how do

The traditional web development model surely we all know, whether it is jsp, asp, php or some magic board engine development, in fact, the truth is the same, are rendering server, the principle is: get the browser sends a request to the corresponding server return to the front end of a html page, rendered by the browser, on a web page presented to the user.

But to say today is that we have been talking about the topic, that is, "before and after the end of the separation of development mode", its benefits is unnecessary to say that we are most familiar with jquery can not be done before and after the end of the separation develop it? The answer is yes!

Specific implementation is very simple, front-end engineers to access back-end interface via ajax (may be encountered cross-domain problems, see an article) as follows:

> $.ajax({
>     type:'get',
>     url:'/api',
>     data:{user:'小明','tel':12345xxxxx}
>     success:function(data){
>         console.log(data)
>     } })

By hand and you can call any ajax api, the background is not difficult to communicate with.
But this rendering is very troublesome, and you can select the rendering methods are: append (), html () , text () , etc., in short, a lot of trouble.

Then talk about mass participation routing problems and issues between pages, I use jQuery to do before and after the end of the separation project in general there is no route, the situation is directly connected to the jump page, although this is very wrong, but it seems nothing approach. This page parameter passing crying can be basically solved, you can get another page address bar, address bar parameters passed by reference js, so as to realize the address bar pass argument about it.

In short, before and after the end of the separation jquery implementation is not perfect, the cost is very high, the novice can try, recommended for advanced learning framework angular.js vue or the like.
Have said the wrong place welcome correction technology cattle comment! The above represents only my personal point of view.

Guess you like

Origin www.cnblogs.com/baimeishaoxia/p/11965790.html