var httpc = new XMLHttpRequest(); // simplified for clarity
httpc.open("POST", url, true); // sending as POST
httpc.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
httpc.onreadystatechange = function() { // Call a function when the
// state changes.
if (httpc.readyState == 4 && httpc.status == 200) {
//MY JSON RESPONSE
alert(JSON.stringify(httpc.responseText));
}
}
httpc.send(params);
上面的代码在 android 4.0 中运行良好,响应以有效的 JSON 格式获取。但是当我在 android 2.3 中运行相同的代码时,我得到了未知格式的响应,并且我的 url 和参数对于两个 android 版本都是相同的。
在 2.3 中,我的回答是。�<code>I�%&/m�{J�J��t��$ؐ@������iG#)�*��eVe]f@�흼��{���{�� ;�N'����?\fdl��J�ɞ!���?~|?"��?�YQ~�里F�������n���/������& ����2����u�~����)`�U��TH��2Ϛ<}S_��Y��z:%����,�o�e��tv� �X��E��{?v��U��V�j�B�s�FU�~�p�Զ�ɢ�i�2[^�i�S��W���_� ��'������
在 4.0 中,我的回复是 [{"email":"","password":"","user_id":"","store_id":"","message":"警告!,错误的电子邮件或密码请重试.","success":"0","nick_name":"","magazine_genre_id":"","magazine_genre_name":"","newspaper_genre_id":"","newspaper_genre_name":"","old_password": "","new_password":"","mode":"","languagecode":"","URL":""}] 在 file:///android_asset/www/project.js:717
Logcat 异常: SyntaxError: Parse error at undefined:1