johnny
johnny

Reputation: 19745

Does ajax require a web service?

If I want to get data to update partially in a page with jquery (or something else) ajax, does the page I call have to be a web service? Or will just any page that returns json or xml be fine?

I guess I'm asking it like this because in asp.net you have "offical" web services. In other languages and frameworks they may not be like that. I know for example that I can create a classic asp page and return an xml document. Is that a web service?

Upvotes: 4

Views: 278

Answers (4)

gregor171
gregor171

Reputation:

For simple tasks, you should return html. As simple as that. For use in jquery you return JSON. No web service is needed, but it is possible to make web service return JSON result, that could be used in your page. This would be a practice when you already have a webservice with data that you need for page. Otherwise it is no need to do so.

Upvotes: 0

Hank Gay
Hank Gay

Reputation: 71979

The page does not have to be an "official" Web Service. It doesn't even have to return JSON or XML, you just need to be able to work with the results in your client code.

In general, an ASP page (or anything else you can send a request to and get a response from via HTTP) can be a "web service", but not a "Web Service".

Upvotes: 4

Matthew Groves
Matthew Groves

Reputation: 26169

It doesn't even have to return JSON or XML--it can return HTML or text that you can just drop into the calling page.

I've used "all of the above" in one place or another.

Upvotes: 9

chaos
chaos

Reputation: 124325

Any URL that returns output that the jQuery (or whatever) processor can understand — JSON, XML, or otherwise — is fine. jQuery cares not at all about "official" web services. No WSDLs here, sir.

Upvotes: 4

Related Questions