js post 提交
public JSONObject submitAnswer(JSONObject json,String postUrl){
String result = null;
try {
result = ClientBuilder.request(this.context, postUrl, json.toString(), "post");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("/..." + result);
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject("{result:'" + result + "'}");
} catch (JSONException e) {
e.printStackTrace();
}
return jsonObject;
}
?
?
js 端调用上面的方法:
$.phonegap.submitpageId=function(pageName){
var info = {url:pageInfoid+pageName};
$.phonegap.getData({
action: 'submitAnswer',
success: function(op) {
window.Control.closePrograssDialog();
// if(op.result == '200') {
// alert('提交成功');
// } else {
// alert('提交失败');
// }
// alert(op.result);
},
failure: function(msg) {
alert(msg);
window.Control.closePrograssDialog();
},
url: JSON.stringify({list:info, postUrl: '提交的地址?pageInfoName='+pageInfoName+'&deviceId='+deviceId+'&pageInfoid='+pageInfoid})
});
};