I just tried to do AsyncTask with aquery. I have been successfully using AsyncTask aquery on some features in my application. But when I try to display data on listfragment error appears. Error that arises is 'method not allowed'
This is my script:
public void callApiMomentApi(String email) {
URL = Constant.URLApi.MOMENT;
Map<String, Object> params = new HashMap<String, Object>();
params.put("email", email);
resultListener.onApiPreCall();
aq.ajaxCancel();
try {
aq.ajax(URL, params, String.class, callback);
} catch (Exception e) {
resultListener.onApiResultError(e.getMessage());
Log.e("Moment","Aquery Error");
}
}
private AjaxCallback<String> callback = new AjaxCallback<String>() {
public void callback(String url, String result, AjaxStatus status) {
if (result != null) {
ApiDao apiDao = null;
try {
apiDao = gson.fromJson((result).toString(), ApiDao.class);
if (apiDao.getSuccess().equals("true")) {
resultListener.onApiResultOk(apiDao.getData().get(0).getMoment());
}
else {
resultListener.onApiResultError(apiDao.getMessage());
Log.e("Moment","Tidak success");
}
} catch (Exception e) {
resultListener.onApiResultError(e.getMessage());
Log.e("Moment","Exception e");
}
} else {
resultListener.onApiResultError(status.getMessage());
Log.e("Moment","Result Null");
}
};
};
Help me please, Thank you in advance
Certainly your URL isn't the good one and the server is sending back a 405 Method Not Allowed.
At least your server doesn't know how to handle it. I don't think the problem is in your Android code.
Check your servlets and your URL.