如何添加此 http 标头
contentType: "application/json; charset=utf-8"
到这个 ajax 查询?
public void asyncJson(){
//perform a Google search in just a few lines of code
String url = "http://www.mysite.com/Services/GetJson";
Map<String, Object> params = new HashMap<String, Object>();
params.put("nNumResults", "100");
aq.ajax(url, params, JSONObject.class, new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject json, AjaxStatus status) {
if(json != null){
//successful ajax call, show status code and json content
Toast.makeText(aq.getContext(), status.getCode() + ":" + json.toString(), Toast.LENGTH_LONG).show();
}else{
//ajax error, show error code
Toast.makeText(aq.getContext(), "Error:" + status.getCode(), Toast.LENGTH_LONG).show();
}
}
});
} // asyncJson