Ajax Web服务架构

What is the difference between:

  1. Using ajax to call web services directly and rendered the result into the html, and
  2. Using ajax to call a local proxy and let the local proxy to call web services?

the biggest difference is database transactions. if your web service layer is orthogonal and fine-grained and common use-cases require multiple calls. often you want to bundle more than one call into a single atomic database transaction: e. g. (debit account A, credit account B).

to do this you must use a local proxy because you cannot demarcate transactions on the client.

I would personally almost always use method 2. This way you have more control over the service being called and can always substitute the proxy with a "mock" service to return pre-defined results for testing. Just my 2 cents.