您好我收到以下错误:
200
SyntaxError: JSON.parse: 意外字符
我在 firebug 中检查了我的 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"
这对我来说似乎没问题,所以我不确定我哪里出错了,为什么我会出错
我的代码如下:
查询:
$(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);
}
任何帮助,将不胜感激。
谢谢