你好我收到以下錯誤:JQuery的越來越JSON.parse:意外的字符
語法錯誤:JSON.parse:意外的字符
我已經檢查了我的JSON的螢火,它說以下內容:
jquery-1.8.3.js (line 2)
POST http://localhost:1579/Comets/Progress/4c691777-2a9f-42ca-8421-d076ab4d0450/1
200 OK
JSON
Sort by key
MsgId "4c691777-2a9f-42ca-8421-d076ab4d0450"
Status 2
CurrentServer "10.10.143.4"
這似乎確定我,所以我不知道我要去的地方錯了,爲什麼我收到一個錯誤
我的代碼folows:
的Jquery:
$(document).ready(function Progress() {
var msgId = $('textarea.msgId').val();
var status = $('textarea.status').val();
$.ajax({
type: 'POST',
url: "/Comets/Progress/" + msgId + "/" + status,
success: function (data) {
//update status
alert("does this work");
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
控制器:
[JsonpFakeFilter]
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult Progress(string msgId, int status, String callback)
{
//todo need to put recursive function on here (status)
//check the ip - has it changed
string strHostName = System.Net.Dns.GetHostName();
var ipHostInfo = Dns.Resolve(Dns.GetHostName());
var ipAddress = ipHostInfo.AddressList[0];
var currentServer = ipAddress.ToString();
var cometJson = new CometJson
{
MsgId = msgId,
Status = status,
CurrentServer = currentServer
};
//check what the status is if it is less than 4 we want to add one
if (status <= 4)
{
status = status + 1;
cometJson = new CometJson
{
MsgId = msgId,
Status = status,
CurrentServer = currentServer
};
return Json(cometJson);
}
return Json(cometJson);
}
任何幫助,將不勝感激。
感謝
你能證明你的服務器返回的螢火看到的JSON字符串? – 2013-03-11 11:44:09
請嘗試記錄Json結果也許它不是正確的Json字符串。 – 2013-03-11 11:48:03
@DarinDimitrov喜的螢火IM看到的MsgId \t 「fc91db57-b35e-4254-82f0-3defb9f4c079」 \t 狀態 \t \t CurrentServer \t 「10.10.143.4」 是這樣的不是你的意思? – anna 2013-03-11 11:50:53