錯誤:錯誤:語法錯誤:JSON.parse:意外的字符錯誤:語法錯誤:JSON.parse:意外的字符+的OAuth
_serviceURl = sharepoint02/LMSRest.svc /休息/ GetDemoOAuthPlan LMSUsername = bfolmer & oauth_consumer_key =二段& oauth_nonce = 8765121 & oauth_signature_method = HMAC-SHA1 & oauth_timestamp = 1363238520 & oauth_version = 1.0 &的PageNumber = 1 &每頁= 5 & SortColumn =課程& SortDirection =真& oauth_signature = V35lYfuMNUxrzVWfUKdOchcbTEQ =」
如果URL從瀏覽器接收到結果。
{
"MyLearningList": [
{
"LearningId": 26,
"Curriculum": "Administrative Law",
"CurriculumURL": null,
"TrainingStatus": "InProgress",
"StartDate": "10/15/2012",
"EndDate": "10/15/2013"
},
{
"LearningId": 2,
"Curriculum": "Architecture",
"CurriculumURL": null,
"TrainingStatus": "InProgress",
"StartDate": "10/15/2012",
"EndDate": "11/15/2013"
},
{
"LearningId": 11,
"Curriculum": "Audit",
"CurriculumURL": null,
"TrainingStatus": "InProgress",
"StartDate": "10/15/2012",
"EndDate": "10/15/2013"
},
{
"LearningId": 21,
"Curriculum": "Automobile Engg.",
"CurriculumURL": null,
"TrainingStatus": "InProgress",
"StartDate": "10/15/2012",
"EndDate": "10/15/2013"
},
{
"LearningId": 32,
"Curriculum": "B. A. M. S. (Bachelor of Ayurvedic Medicine and Surgery)",
"CurriculumURL": null,
"TrainingStatus": "InProgress",
"StartDate": "10/15/2012",
"EndDate": "10/5/2013"
}
],
"PageSize": 5,
"CurrentPageNumber": 1,
"TotalRecordCount": 39,
"TotalPageCount": 8,
"NextPageUrl": "sharepoint02:50000/LMSRest.svc/rest/GetDemoOAuthPlan?LMSUsername=bfolmer&PageNumber=2&PageSize=5&SortColumn=Curriculum&SortDirection=True",
"PreviousPageUrl": ""
}
以下是我的JavaScript代碼
功能BindGrid <%=標籤%>(_的serviceURL){
//Append the Loading
$('#tbl<%=Tag %>').append('<tr class="loading"><td colspan="5"><img src="/Style Library/LMS/images/loading.gif" align="top" /> Loading...</td></tr>');
$.support.cors = true;
$.ajax({
type: "GET",
url: _serviceURL,
contentType: "application/json",
timeout: 17000,
dataType: "json",
success: function (_result) {
//Bind the Header
BindHeader<%=Tag %>();
if(_result == null || _result == "")
{
$('#tbl<%=Tag %>').append('<tr class="bottom"><td colspan="5" class="table-data-error">Error : Some problem fetching the data. Please contact IT team.</td></tr>');
return ;
}
///Catalog
var _myObject = (typeof _result) == 'string' ? eval('(' + _result + ')') : _result;
//Bind the values
$("input[id*='txtPageSize'][Tag='<%=Tag %>']").val(_myObject.PageSize);
$("input[id*='txtCurrentPageNumber'][Tag='<%=Tag %>']").val(_myObject.CurrentPageNumber);
$("input[id*='txtTotalRecordCount'][Tag='<%=Tag %>']").val(_myObject.TotalRecordCount);
$("input[id*='txtTotalPageCount'][Tag='<%=Tag %>']").val(_myObject.TotalPageCount);
$("input[id*='txtNextPageUrl'][Tag='<%=Tag %>']").val(_myObject.NextPageUrl);
$("input[id*='txtPreviousPageUrl'][Tag='<%=Tag %>']").val(_myObject.PreviousPageUrl);
//Bind the grid
if (_myObject.MyLearningList == null || _myObject.MyLearningList.length == 0) {
$('#tbl<%=Tag %>').append('<tr class="bottom"><td colspan="5" class="table-data-message">No course found.</td></tr>');
return;
}
//ITEM START
for (i = 0; i < _myObject.MyLearningList.length; i = i + 1) {
//Get the values
var Curriculum = _myObject.MyLearningList[i].Curriculum;
var _Status = _myObject.MyLearningList[i].TrainingStatus;
var _startDate = _myObject.MyLearningList[i].StartDate;
var _endDate = _myObject.MyLearningList[i].EndDate;
var _css = "odd";
if ((i + 1) % 2 == 0)
{ _css = "even"; }
//Append
$('#tbl<%=Tag %>').append("<tr class='" + _css + "'><td>" + Curriculum + "</td><td>" + _Status + "</td><td>" + _startDate + "</td><td>" + _endDate + "</td></tr>");
}
//ITEM END
//PAGING START
var _trFooter = "";
if(_myObject.TotalRecordCount > 0)
{
if(_myObject.PreviousPageUrl != "")
{
_trFooter = _trFooter + '<td style="width:25%;"><a href="javascript:Previous<%=Tag %>();"><< Previous</a><td>';
}
else{
_trFooter = _trFooter + '<td style="width:25%;"> <td>';
}
_trFooter = _trFooter + "<td style='width:50%;font-weight:bold;text-align:center;' nowrap='nowrap'>Page No : "+ _myObject.CurrentPageNumber +" of "+ _myObject.TotalPageCount +"</td>";
if(_myObject.NextPageUrl != "")
{
_trFooter = _trFooter + '<td style="width:25%;text-align:right;"><a style="float:right;width:50px;" href="javascript:Next<%=Tag %>();">Next >></a></td>';
}
else{
_trFooter = _trFooter + '<td style="width:25%;"> <td>';
}
$('#tbl<%=Tag %>').append('<tr class="bottom"><td colspan="4" class="table-data-paging"><table cellspacing="0" border="0" cellpadding="0" style="width:100%;"><tr>'+ _trFooter +'</tr></table></td></tr>');
}
//PAGING END
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
//Binds the header
BindHeader<%=Tag %>();
//Show the error
$('#tbl<%=Tag %>').append('<tr class="bottom"><td colspan="5" class="table-data-error">Error : Some error occoured fetching the data. Please contact IT team. Error :'+errorThrown+'</td></tr>');
}
});
}
請其緊急幫助我。