我試圖加載通過jQuery.getJSON()的一些數據,但它不工作:試圖使用jquery ajax但無法解析JSON?
這裏是我的JSON:
{didwork=true,userid=123}
,或者是
{didwork=false,userid=0}
這裏我的Javascript:
$.ajax({
data["username"] = "u"
data["password"] = "p";
url: https://www.myurl.com/json.php,
dataType: 'json',
data: data,
success: function(json){
//fill it into div
}
});
如果你曾經好奇,如果你的JSON是或不是正確的,我'd建議使用[JsonLint.com](http://jsonlint.com/)。 – 2012-04-28 15:34:24
該代碼是語法錯誤;它不可能工作。您應該*始終*打開您的JavaScript控制檯。 – Pointy 2012-04-28 15:34:53