Can ajax call be done in Android?
ajax, android
Solution
You can use my droidQuery library, which is The Android port of jQuery, and includes most of the features and syntax of jQuery, including Ajax. For example:
$.ajax(new AjaxOptions().url("http://www.example.com").type("GET").dataType("json").success(new Function() {
@Override
public void invoke($ d, Object... args) {
JSONObject json = (JSONObject) args[0];
//TODO handle json. If expecting a JSONArray, just cast args[0] to JSONArray.
}
}).error(new Function() {
@Override
public void invoke($ d, Object... args) {
AjaxError error = (AjaxError) args[0];
Toast.makeText(MyActivity.this, "Error (" + error.status + "): " + error.reason, Toast.LENGTH_LONG).show();
}
}));
Problem
I'm developing an application in which I've got search option. In that search box, if I type 'a' I want all names of all my friends starting with a, which I'll get from web server. But for that I've to make request simultaneously with typing each letter. But when I googled, I got mixed reactions. Some people said Ajax call is not possible in Android. Basically Android is based on java. Then why is not possible to perform AJAX calls. Could anyone guide me to a good link related to AJAX call in Android if it is possible ?