2013-10-23 83 views
0

的Android代码AQuery的JSONObject AjaxStatus错误

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()); 
    } 

错误代码

ERROR:http://www.aropasoft.com/adpocket/member/login|-103|transform错误

为什么错误我不;知道... ..

回答

0

尝试

aq.ajax(strHostName, localHashMap, String.class, new AjaxCallback<String>() 

那么字符串

0

Aquery需要一个JSONObject解析JSON。改变这一行

echo json_encode($arrNotice); 

此:

echo json_encode($arrNotice, JSON_FORCE_OBJECT);