Thanks.
jsonp works by wrapping the resulting json with a javascript callback
and then sourcing that resulting text as a javascript "script". Due
to Darts similar-to-js syntax, optional typing, and embeddable json,
its very possible that the resulting text could parse as if it were
Dart, but its not guaranteed. To be safe, you would need Dart
versions of the server call, which most services don't provide (One
person suggested that you could implement your own server proxy that
would speak "dart-jsonp"). However, even if you had a server that did
support "dart-jsonp", current browsers don't have dart vm's. As for
using the dartc, the javascript which dart compiles has mangled
function names (and possibly worse: inlined/altered function
signatures, etc) as so you cannot reliably use that code in a
javascript callback which you need for jsonp.
So, I never did find a valid solution. Sorry.
Bob: I would really suggest/request that the team think about jsonp a
little. Thanks!
On Nov 29, 4:29 pm, Bob Nystrom <rnyst...@google.com> wrote:
--
Ali Afshar | www.googplus.org/ali | Google Developer Relations
Sure, I am writing a blog post, but for now consider this untested but
simplest example I could think of:
<html>
<body>
<script type="text/javascript" src="Jsonp.dart.app.js"></script>
<script type="text/javascript">
function callback(s) {
window.postMessage(s, '*');
}
</script>
</body>
</html>
class Jsonp {
void run() {
window.on.message.add(codeReceived, false);
ScriptElement s = document.createElement('script');
// Jsonp call
s.src = 'http://my-api-uri?callback=callback';
document.nodes.add(s);
}
void codeReceived(MessageEvent e) {
// e.data is your Json