Home  >  Article  >  Backend Development  >  Ajax access optimization in MVVM mode

Ajax access optimization in MVVM mode

WBOY
WBOYOriginal
2016-10-22 12:06:391349browse

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){<br> },'json');<br> $.get('http://server/shop/getlist','',function(res){<br> },'json');<br> $.get('http://server/user/getinfo','',function(res){<br> },'json');<br> $.get('http://server/shop/getLoveShop','',function(res){<br> },'json');<br> $.get('http://server/ad/5','',function(res){<br> },'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.

Statement:
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 admin@php.cn
Previous article:求助交流Next article:curl数据接受问题