Ajax access optimization in MVVM mode

WBOY
Release: 2016-10-22 12:06:39
Original
1241 people have browsed it

In a page, you need to access the route as follows:
http://server/user/getinfo
http://server/shop/getlist
http://server/shop/getLoveShop
http://server/ad/5

Assuming that the ajax route-by-route execution will be like this: $.get('http://server/user/getinfo','',function(res){
},'json');
$.get('http://server/shop/getlist','',function(res){
},'json');
$.get('http://server/user/getinfo','',function(res){
},'json');
$.get('http://server/shop/getLoveShop','',function(res){
},'json');
$.get('http://server/ad/5','',function(res){
},'json');
There will definitely be no problem in executing this way.
I want to optimize these routing accesses and centralize them for execution in an AJAX.
The execution method is as follows:
var str = 'route[]=/user/getinfo&';
str+='route[]=/shop/getlis&';
str+='route[]=/shop/getLoveShop&';
str+='route[]=/ad/5';
$.post('/route/call' , str,function(res){

},'json');

I want to combine them to execute so many routing access commands at one time, but now I don’t know how to achieve it.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!