Using XMLHttpRequests

조회수 929회
읽지 않은 첫 메시지로 건너뛰기

Alexander Orlov

읽지 않음,
2011. 10. 14. 오후 5:08:2511. 10. 14.
받는사람 General Dart Discussion
I believe XMLHttpRequest is part of the HTML5 standard? Is there a way
to make XMLHttpRequests like in JavaScript?

Bob Nystrom

읽지 않음,
2011. 10. 14. 오후 5:25:2611. 10. 14.
받는사람 Alexander Orlov, General Dart Discussion
On Fri, Oct 14, 2011 at 2:08 PM, Alexander Orlov <alexand...@loxal.net> wrote:
I believe XMLHttpRequest is part of the HTML5 standard? Is there a way
to make XMLHttpRequests like in JavaScript?

Yes, both the classic DOM library ('dart:dom') and our newer API ('dart:html') support it. It's a little rough right now, but you can see an example of using it in Swarm: https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/client/samples/swarm/DataSource.dart#224.

- bob

Alexander Orlov

읽지 않음,
2011. 10. 14. 오후 5:28:3311. 10. 14.
받는사람 General Dart Discussion
Ah! Exactly what I need! Thx Bob!
(imperative posting :)

On Oct 14, 11:25 pm, Bob Nystrom <rnyst...@google.com> wrote:
> On Fri, Oct 14, 2011 at 2:08 PM, Alexander Orlov
> <alexander.or...@loxal.net>wrote:
>
> > I believe XMLHttpRequest is part of the HTML5 standard? Is there a way
> > to make XMLHttpRequests like in JavaScript?
>
> Yes, both the classic DOM library ('dart:dom') and our newer API
> ('dart:html') support it. It's a little rough right now, but you can see an
> example of using it in Swarm:https://code.google.com/p/dart/source/browse/branches/bleeding_edge/d...
> .
>
> - bob

Erik Ashcraft

읽지 않음,
2011. 11. 14. 오전 10:24:3611. 11. 14.
받는사람 General Dart Discussion
The code from the link shows a request with async = false:
final req = new XMLHttpRequest();
req.open('GET', '${Sections.home}/data/$name', false);
req.send();
_htmlBody = req.responseText;

Is there an example with async = true?

On Oct 14, 3:25 pm, Bob Nystrom <rnyst...@google.com> wrote:
> On Fri, Oct 14, 2011 at 2:08 PM, Alexander Orlov
> <alexander.or...@loxal.net>wrote:
>
> > I believe XMLHttpRequest is part of the HTML5 standard? Is there a way
> > to make XMLHttpRequests like in JavaScript?
>
> Yes, both the classic DOM library ('dart:dom') and our newer API
> ('dart:html') support it. It's a little rough right now, but you can see an
> example of using it in Swarm:https://code.google.com/p/dart/source/browse/branches/bleeding_edge/d...
> .
>
> - bob

chrisbuckett

읽지 않음,
2011. 11. 14. 오전 11:11:0011. 11. 14.
받는사람 General Dart Discussion
This post: http://dartwatch.com/index.php/2011/11/exploring-dart-client-server-written-in-dart/
has an example using XMLHttpRequest,

you just need to change the line in client.dart
req.open("POST",url,false);
to
req.open("POST",url,true);

and the event handler will run async.

The code is also in github here: https://github.com/chrisbu/dartwatch-client-server-example

Regards
Chris.


---------------------
http;//dartwatch.com
전체답장
작성자에게 답글
전달
새 메시지 0개