我正在从数据库中获取数据,并将数据在ASP.NET MVC视图页面中显示为表格格式。下面是Ajax调用。我将返回数据作为JSON字符串。我不知道为什么。对于所有视图页面,我都将其作为JSON对象。
尽管该值在JSON字符串中获取,但我尝试使用“ JSON.parse(jsonData)”转换为JSON对象。它在我的本地环境中运行良好。当我在舞台上部署代码时。生产线在Json Parse断裂。
为什么我遇到此错误。代码中有什么用吗?
JSON字符串:
void * funcao_somadora(void * es){
int i;
estrutura_geral * const estrutura = es;
pthread_mutex_lock(estrutura->mutex);
pthread_cond_signal(estrutura->cond);
pthread_mutex_unlock(estrutura->mutex);
for(i=0;i<barreira;++i){
pthread_mutex_lock(estrutura->mutex);
while(items_buffer == 0) {
pthread_cond_wait(estrutura->consumir, estrutura->mutex);
}
soma_global+=buffer[items_buffer];
items_buffer--;
printf("A thread somadora: somou %d, existem %d elemnetos no buffer\n",buffer[items_buffer],items_buffer);
if(items_buffer==0){
sched_yield();
//pthread_cond_signal(estrutura->produzir);
}
pthread_mutex_unlock(estrutura->mutex);
}
printf("A tarefa somadora está de saída\n");
pthread_exit(NULL);
}
AJAX通话:
[{"SuppNum":null,"Documentumid":"090111738011c814:Supplier Needful Info.xlsx:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","DocDescription":"Paper Agreement","CreateDate":"05/11/2019","Userid":null,"LastChnageDate":null,"LastChnageUserid":null,"DocTypeCode":"40","AttachmentFilename":"Supplier Needful Info","ExpirtyDate":null,"IsDeleted":null,"DocTypeCodeDescription":"PII Paper Agreement ","ContentType":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},{"SuppNum":null,"Documentumid":"090111738011c2c2:WP_SQL_Query1.pdf:application/pdf","DocDescription":"Expense Report","CreateDate":"05/14/2019","Userid":null,"LastChnageDate":null,"LastChnageUserid":null,"DocTypeCode":"27","AttachmentFilename":"WP_SQL_Query1","ExpirtyDate":null,"IsDeleted":null,"DocTypeCodeDescription":"Expense ","ContentType":"application/pdf"},{"SuppNum":null,"Documentumid":"090111738011c2cc:UiPath-Level1_Certificate.pdf:applicat ion/pdf","DocDescription":"Paper DOC","CreateDate":"05/14/2019","Userid":null,"LastChnageDate":null,"LastChnageUserid":null,"DocTypeCode":"40","AttachmentFilename":"UiPath-Level1_Certificate","ExpirtyDate":null,"IsDeleted":null,"DocTypeCodeDescription":"PII Paper Agreement ","ContentType":"application/pdf"},{"SuppNum":null,"Documentumid":"090111738011c2e9:Communication Plan 865944.docx:application/vnd.openxmlformats-officedocument.wordprocessingml.document","DocDescription":"DOCS","CreateDate":"05/16/2019","Userid":null,"LastChnageDate":null,"LastChnageUserid":null,"DocTypeCode":"1","AttachmentFilename":"Communication Plan 865944","ExpirtyDate":null,"IsDeleted":null,"DocTypeCodeDescription":"Insurance Documents ","ContentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},{"SuppNum":null,"Documentumid":"090111738011c2ea:Communication Plan 865944.docx:application/vnd.openxmlformats-officedocument.wordprocessingml.docum ent","DocDescription":"Amedments","CreateDate":"05/17/2019","Userid":null,"LastChnageDate":null,"LastChnageUserid":null,"DocTypeCode":"20","AttachmentFilename":"Communication Plan 865944","ExpirtyDate":null,"IsDeleted":null,"DocTypeCodeDescription":"Amendment ","ContentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},{"SuppNum":null,"Documentumid":"090111738011c310:How to attach in OSA.pdf:application/pdf","DocDescription":"","CreateDate":"05/18/2019","Userid":null,"LastChnageDate":null,"LastChnageUserid":null,"DocTypeCode":"32","AttachmentFilename":"How to attach in OSA","ExpirtyDate":null,"IsDeleted":null,"DocTypeCodeDescription":"EVP Attachment ","ContentType":"application/pdf"},{"SuppNum":null,"Documentumid":"090111738011c2ec:WP_SQL_Query1.pdf:application/pdf","DocDescription":"","CreateDate":"05/18/2019","Userid":null,"LastChnageDate":null,"LastChnageUserid":null,"DocTypeCode":"27","AttachmentFi lename":"WP_SQL_Query1","ExpirtyDate":null,"IsDeleted":null,"DocTypeCodeDescription":"Expense ","ContentType":"application/pdf"},{"SuppNum":null,"Documentumid":"090111738011c2ed:SyamOld_Passport.pdf:application/pdf","DocDescription":"","CreateDate":"05/18/2019","Userid":null,"LastChnageDate":null,"LastChnageUserid":null,"DocTypeCode":"27","AttachmentFilename":"SyamOld_Passport","ExpirtyDate":null,"IsDeleted":null,"DocTypeCodeDescription":"Expense ","ContentType":"application/pdf"}]
控制器方法:
$("#btnVendorSearch").click(function() {
if (RequiredFieldValidate() != false) {
var SupplierNumber = $('#txtVendorNumber').val();
$.ajax({
type: "POST",
url: getExactPath('/Supplier/GetSupDocuments'),
async: false,
data: {
SupplierNo: SupplierNumber
},
dataType: 'Json',
success: function(jsonData) {
var jsonobj = JSON.parse(jsonData);
if (jsonobj.error == "" || jsonobj.error == undefined) {
FillGrid(jsonobj);
} else {
console.log(jsonobj.error);
}
},
error: function() {
alert("Unable to fetch the data");
}});}});
它应该返回如下。请帮助我。
public JsonResult GetSupDocuments(string SupplierNo) {
string Error = "";
DocumentumUtil dUtil = new DocumentumUtil();
List < Attachment > AttachmentDetails = new List < Attachment > ();
try {
AttachmentDetails = dUtil.GetSupplierAttachments(SupplierNo);
return this.Json(AttachmentDetails);
} catch (System.Exception ex) {
Error = ex.Message;
}
return this.Json(new {error = Error});
}
答案 0 :(得分:0)
JSON字符串现在正在解析为数组对象。
jQuery.parseJSON()