开发者

Best practices for loading model on a page in AJAX applications?

开发者 https://www.devze.com 2023-03-26 12:19 出处:网络
We\'ve recently started using ExtJS with .NET web services to build ajax applications.I\'m wondering what best practices are in pulling down the model client side.For example, I have a form with 10 co

We've recently started using ExtJS with .NET web services to build ajax applications. I'm wondering what best practices are in pulling down the model client side. For example, I have a form with 10 comboboxes. Do I make 10 individual 开发者_开发知识库ajax calls and load each corresponding combobox as I get the results or do I make one web service call which then returns me the "model" of all 10 lists for each of the dropdowns? What are people doing in this regard?

For the first approach, individual web services, I was thinking one advantage is that the payload is smaller and you can take advantage of the multiple threads avail within the browser(2-4 available) and this concurrency can be increased with different domain names for each request. This gives some concurrency in fetching the model. What do you guys think?


Do I make 10 individual ajax calls and load each corresponding combobox as I get the results or do I make one web service call which then returns me the "model" of all 10 lists for each of the dropdowns?

Make a new web service that loads the model for all 10 and whatever else you need to return. Adding new web services is not hard on the server; making 10+ HTTP requests that could be trimmed down to 1, however, can be very hard on the server. With 100 users loading that form, the server would have to handle at least 1,100 requests (At least 1 for the initial page load and then 10 requests for all of those AJAX calls).

There's no reason your web service couldn't return a structure like this for ExtJS:

{
    chk1: true,
    chk2: false,
    chk3: true...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消