Duke1992
Duke1992

Reputation: 185

how to use Ajax to get content from JSON files dynamically in DART?

I know how to use JSON in dart also communicating with a server using the HttpRequest API from the dart:html library and parsing JSON data using the dart:convert !!https://www.dartlang.org/articles/json-web-service/

I am looking for Dynamic content loading using Ajax asynchronous methods or calls in DART! ..

like .. the web page need to load content dynamically if there is any change or update in JSON files in server! ..

And how to do this in Angular Dart!?

Upvotes: 0

Views: 277

Answers (1)

Danny Tuppeny
Danny Tuppeny

Reputation: 42353

There's no way to be notified when something changes on the server without either a) polling for changes (this can be pretty wasteful) or b) having the server notify you.

For (a), you could create a periodic timer that fetches the JSON or checks whether it's been updated (you'd need some way of checking this with the server).

A better fit would be something like Web Sockets, with the server able to push your JSON to the client whenever it changes. However, this is quite an architecture change from pulling JSON from the server, because you would need to be holding web sockets open between the server and all clients that have the page loaded, so the server can send the data to them all whenever it changes.

There are some samples of using Web Sockets on the Dart site; but bear in mind you'll need something on the server, this won't work if you only have access to the client.

Upvotes: 1

Related Questions