アプリのサーバー側で JSON ライブラリを使用せずに JSON を取得するために java.Object.toString() をオーバーライドしています。
jQuery のバージョン1.9.0
と JDK のバージョン1.6.21
に対する応答として:
var jqxhr = $.ajax(url:"/getAvailableAddress.do",
type:"GET",
data:"cat=PreOrder&task=getAvailableAddress"+$(form).serialize() )
.done(function(response) { console.log(response); })
.fail(function() { alert("error"); })
.always(function() { alert("complete"); });
サーバーから次の JSON を取得しています。
{
"response": [
{
"alk": "123456",
"qualifier": "golden",
"buildingname": "Rose Appartments",
"buildingnumber": "1245",
"Street": "Nehru Street",
"Town": "Kolkata",
"Postcode": "MQK 456"
},
{
"alk": "123457",
"qualifier": "platinum",
"buildingname": "Lily Appartments",
"buildingnumber": "1585",
"Street": "Modi Street",
"Town": "Bangalore",
"Postcode": "476 AKQ"
}
]
}
次のことをしようとすると:
var result = $.parseJSON(response);
alert(result.response[0].alk);
Jquery ファイルで JavaScript エラーが発生します。
Uncaught SyntaxError: Unexpected token o jquery-1.9.0.min.js:1
st.extend.parseJSON jquery-1.9.0.min.js:1
(anonymous function)
しかし、以下を使用すると、エラーはまったく発生しません。
var result = eval(response);
alert(result.response[0].alk);
jQuery Parse の何が間違っていますか?