我遇到了一個小問題。我正在嘗試使用jQuery $.ajax
調用JSON文件來訪問我在線複選並且我的JSON代碼有效。當我進行調用時,它會在JSON中帶有語法錯誤的解析錯誤。
您可以通過訪問http://michael-nolan.com/
在這裏的錯誤是我的javascript:
$(document).ready(function()
{
$.ajax(
{ type: "GET",
url: 'projects/projects.json',
dataType: "json",
success: function(results)
{
console.log("Success!");
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
console.log(textStatus); console.log(errorThrown);
}
});
});
,這裏是我的JSON
{
"projects":
[
{
"title":"Adobe Suite",
"description":"Some stuff",
"imgsrc":"img/adobe_suite_description.png"
},
{
"title":"Gridlock",
"description":"Stuff",
"imgsrc":"img/gridlock_description.png"
},
{
"title":"Open Cart",
"description":"more stuff",
"imgsrc":"img/opencart_description.png"
}
]
}
您是否使用過Fiddler(http://www.fiddler2.com/fiddler2/)來確保服務器發送了您期望的內容? – 2013-02-28 05:15:50
你能顯示錯誤嗎?還像tmack說試試它http://jsfiddle.net/,以便您可以複製它,我們可以看到它。 http://jsfiddle.net/vqagE/爲我解析罰款。哇,對不起,完全不同。我將不得不自己檢查一下。 – John 2013-02-28 05:17:01
@John我更新了我的問題,並提供了鏈接到網站的問題正在發生。 – Nolski 2013-02-28 05:23:57