Ajax与Web服务

what is different between ajax and webservices. Anybody provide with some examples?

The term "Ajax" is generally used :

  • When the request is sent by a browser (client-side) to a server
  • When the transfered data is XML or JSON or HTML.


The word "webservice" is generally used :

  • When the request is sent by a server to another server, without a browser being involved
  • When the transfered data is SOAP -- at least when it's a SOAP webservice ^^ (Opposed to REST, for instance, which generally doesn't imply SOAP)


But I'd say that Ajax is basically some specific kind of webservice.

It's nonsensical to compare these things.

"Ajax" is a process that occurs in the browser. It is the act of calling some local server-side page, without refreshing the "main" viewing area, and then doing various things with that result (grabbing the data, making changes, changing the existing DOM (adding elements), whatever).

Webservices are a Serverside-thing that allows you to call methods, in your code, but have that call actually go to a remote machine. The call to the Webservice is generally also made server-side.

i think ajax and web services are kind of similar, here is why i think so. as i understood it, in your app sometimes you will have to implement an "API" which has several useful functions. and it is those functions which are called "web services". these 'functions' acts in response to the http requests and "does" something with the data provided. in ajax siimilar kind of work happens as well,just through javascript thats it. so, to sum it all up, an API has 'web services' within it, and ajax behaves like 'web services'. in this manner, yes i think it is correct to call ajax and web services similar.

Asynchronous JavaScript and XML (AJAX) is not, strictly speaking, a kind-of Web Service. It is instead a pattern with which (client-side/browser) web pages consume Web Services using JavaScript and XML (or JSON).