Android代码
strUID = ((AQuery)aq.id(R.id.login_id)).getText().toString();
strPW = ((AQuery)aq.id(R.id.login_password)).getText().toString();
HashMap localHashMap = new HashMap();
localHashMap.put("userid", strUID);
localHashMap.put("password", strPW);
aq.ajax(strHostName, localHashMap, JSONObject.class, new AjaxCallback<JSONObject>()
{
public void callback(String paramString, JSONObject paramJSONObject, AjaxStatus paramAjaxStatus)
{
if(paramJSONObject != null)
{
Log.d("LoginSignup", "LoginProcess call try : " + paramAjaxStatus.getCode() + " | " + paramJSONObject.toString());
return;
}
else
{
Log.d("LoginSignup", "ERROR : " + paramString + "|" + paramAjaxStatus.getCode() + "|" + paramAjaxStatus.getMessage());
return;
}
}
});
服务器PHP代码
$arrMine = $db->rawQuery($arrQuery);
//echo json_encode($arrMine);
// Only One
for($i=0;$i<count($arrMine);$i++){
$objResult->usn = $arrMine[$i]['usn'];
$objResult->userid = $arrMine[$i]['userid'];
$objResult->password = $arrMine[$i]['password'];
break;
}
//print_r($objResult);
echo json_encode($arrNotice);
} catch(Exception $e){
echo json_encode($e->getMessage());
}
错误代码
错误:http://www.aropasoft.com/adpocket/member/login|-103|transform错误
为什么错误我不知道.....
答案 0 :(得分:0)
尝试
aq.ajax(strHostName, localHashMap, String.class, new AjaxCallback<String>()
然后从字符串
解析json答案 1 :(得分:0)
Aquery需要一个JsonObject。改变这一行
echo json_encode($arrNotice);
为此:
echo json_encode($arrNotice, JSON_FORCE_OBJECT);