Initialize the timer before adding the script in case it gets run synchronously
from cache.
Patch by: abrodersen
Review by: dwolf, jat
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6139 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/jsonp/client/JsonpRequest.java b/user/src/com/google/gwt/jsonp/client/JsonpRequest.java
index 43699ec..7d64af1 100644
--- a/user/src/com/google/gwt/jsonp/client/JsonpRequest.java
+++ b/user/src/com/google/gwt/jsonp/client/JsonpRequest.java
@@ -142,7 +142,6 @@
script.setType("text/javascript");
script.setId(callbackId);
script.setSrc(uri.toString());
- getHeadElement().appendChild(script);
timer = new Timer() {
@Override
public void run() {
@@ -150,6 +149,7 @@
}
};
timer.schedule(timeout);
+ getHeadElement().appendChild(script);
}
@SuppressWarnings("unused") // used by JSNI