final Function onSuccess) {\r
Ajax.getJSON(url, data, onSuccess);\r
}\r
+ \r
+ /**\r
+ * Perform an ajax request to the server using scripts tags and\r
+ * parsing the json response. The request is not subject to the \r
+ * same origin policy restrictions.\r
+ * \r
+ * Server side should accept a parameter to specify the callback\r
+ * funcion name, and it must return a valid json object wrapped\r
+ * this callback function.\r
+ * \r
+ * Example:\r
+ <pre>\r
+ Client code:\r
+ getJSONP("http://server.exampe.com/getData.php",$$("myCallback:'?', otherParameter='whatever'"), \r
+ new Function(){ public void f() {\r
+ Properties p = getDataProperties();\r
+ alert(p.getStr("k1");\r
+ }});\r
+ \r
+ Server response:\r
+ myCallback({"k1":"v1", "k2":"v2"});\r
+ </pre>\r
+ * \r
+ */ \r
+ public static void getJSONP(String url, Properties data,\r
+ final Function onSuccess) {\r
+ Ajax.getJSONP(url, data, onSuccess);\r
+ }\r
\r
protected static DocumentStyleImpl getStyleImpl(){\r
if (styleImpl == null){\r
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node;
+import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.js.JsUtils;
final String dataType = settings.getDataType();
if ("jsonp".equalsIgnoreCase(dataType)) {
- Method httpMethod = resolveHttpMethod(settings);
String data = resolveData(settings);
- String url = resolveUrl(settings, httpMethod, data);
+ String url = resolveUrl(settings, RequestBuilder.GET, data);
int timeout = settings.getTimeout();
getJSONP(url, onSuccess, onError, timeout);
return;
}
public static void getJSONP(String url, Function success, Function error, int timeout) {
- if (!url.contains("=?")) {
+ if (!url.contains("=?") && !url.contains("callback=")) {
url += (url.contains("?") ? "&" : "?") + "callback=?";
}
url += "&_=" + System.currentTimeMillis();