无法在Ajax Json中加载资源 [英] Getting Failed to load resource in Ajax Json

查看:81
本文介绍了无法在Ajax Json中加载资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是MVC Ajax Json的新手。我有下面提到的功能,它将返回整个模型。虽然访问代码我没有得到任何错误,但我没有得到Json成功函数中的数据。请有人帮忙。



Jquery功能:

  function  EditProduct(action,dealID,dealWorkFlowID){
debugger ;
$ .ajax({
url:' / Deal / GetInfo /'
类型:' GET'
dataType:' json'
data:' id =' + dealID,
成功: function (data){
PopulateDealWorkflowDepositsTable(data ,' tableDepositDealEditProduct' true , - 1,-1);
},
错误: function (x,y,z){
alertify.error(genericErrorMessage) );
$(' #loaderSelectProducts')。css(' display'' none');
}
});
}





控制器:

 [System.Web .Mvc.HttpGet] 
public JsonResult GetInfo( string id)
{
DealModel dealWorkFlow = this .DealProcessor.GetDeal(Convert.ToInt32(id));
return Json(dealWorkFlow,JsonRequestBehavior.AllowGet);
}





型号:

  public   class  DealModel 
{
public int DealId {get;组; }

public int ClientId {get;组; }

public string DealShareId {get;组; }

public DealType DealType {get;组; }

public 状态状态{get;组; }

public SubStatus SubStatus {get;组; }

public string SDApproverRACF {get;组; }

public string SDApproverISV {get;组; }

public DateTime CreatedDate {get;组; }

public DateTime RespondByDate {get;组; }

public DateTime? ExpiryDate {get;组; }

public DateTime? AgreementDate {get;组; }

public DateTime LastUpdatedDate {get;组; }

public DateTime? ReviewDate {get;组; }

public string LastUpdatedBy {get;组; }

public ClientInformationModel ClientInfoModel {get;组; }

public DealInformationModel DealInfoModel {get;组; }

public DealWorkflowModel DealWorkflowModel {get;组; }

public 列表< DealAdjustmentModel> DealAdjustments {get;组; }

public 列表< DealNoteModel> DealNotes {得到;组; }

public DealModel(){}

public DealModel(ClientInformationModel clientModel,DealInformationModel dealInfoModel,DealWorkflowModel dealWorkflowModel)
{
this .ClientInfoModel = clientModel;

this .DealInfoModel = dealInfoModel;

this .DealWorkflowModel = dealWorkflowModel;
}
}





Chrome错误:



无法加载资源:服务器响应状态为500(内部服务器错误)http:// localhost / Hermes / Deal / GetInfo /?id = 922

< br $>




请分享您的想法或解决方案以解决此错误。



谢谢

Gogulnath

解决方案

.ajax({
url:' / Deal / GetInfo /'
类型:' GET'
dataType:' json'
数据:' id =' + dealID,
成功: function (data){
PopulateDealWorkflowDepositsTable(data,' tableDepositDealEditProduct' true , - 1,-1);
},
错误: function (x,y,z){
alertify.error(genericErrorMessage);


' #loaderSelectProducts')。css(' display'' );
}
});
}





控制器:

 [System.Web .Mvc.HttpGet] 
public JsonResult GetInfo( string id)
{
DealModel dealWorkFlow = this .DealProcessor.GetDeal(Convert.ToInt32(id));
return Json(dealWorkFlow,JsonRequestBehavior.AllowGet);
}





型号:

  public   class  DealModel 
{
public int DealId {get;组; }

public int ClientId {get;组; }

public string DealShareId {get;组; }

public DealType DealType {get;组; }

public 状态状态{get;组; }

public SubStatus SubStatus {get;组; }

public string SDApproverRACF {get;组; }

public string SDApproverISV {get;组; }

public DateTime CreatedDate {get;组; }

public DateTime RespondByDate {get;组; }

public DateTime? ExpiryDate {get;组; }

public DateTime? AgreementDate {get;组; }

public DateTime LastUpdatedDate {get;组; }

public DateTime? ReviewDate {get;组; }

public string LastUpdatedBy {get;组; }

public ClientInformationModel ClientInfoModel {get;组; }

public DealInformationModel DealInfoModel {get;组; }

public DealWorkflowModel DealWorkflowModel {get;组; }

public 列表< DealAdjustmentModel> DealAdjustments {get;组; }

public 列表< DealNoteModel> DealNotes {得到;组; }

public DealModel(){}

public DealModel(ClientInformationModel clientModel,DealInformationModel dealInfoModel,DealWorkflowModel dealWorkflowModel)
{
this .ClientInfoModel = clientModel;

this .DealInfoModel = dealInfoModel;

this .DealWorkflowModel = dealWorkflowModel;
}
}





Chrome错误:



无法加载资源:服务器响应状态为500(内部服务器错误)http:// localhost / Hermes / Deal / GetInfo /?id = 922

< br $>




请分享您的想法或解决方案以解决此错误。



谢谢

Gogulnath


您可以尝试以下方法,我已将数据更改为JSON格式:

 功能 EditProduct(action,dealID,dealWorkFlowID){
debugger ;

Hi All,

I am new to the MVC Ajax Json. I have the function mentioned below which will return the whole model. While accessing the code i dont get any errors but i dont get the data in Json success function. Please anybody help on this.

Jquery Function:

function EditProduct(action, dealID, dealWorkFlowID) {
    debugger;
    $.ajax({
        url: '/Deal/GetInfo/',
        type: 'GET',
        dataType: 'json',
        data: 'id=' + dealID,
        success: function (data) {
            PopulateDealWorkflowDepositsTable(data, 'tableDepositDealEditProduct', true, -1, -1);
        },
        error: function (x, y, z) {
            alertify.error(genericErrorMessage);
            $('#loaderSelectProducts').css('display', 'none');
        }
    });
}



Controller :

[System.Web.Mvc.HttpGet]
       public JsonResult GetInfo(string id)
       {
           DealModel dealWorkFlow = this.DealProcessor.GetDeal(Convert.ToInt32(id));
           return Json(dealWorkFlow, JsonRequestBehavior.AllowGet);
       }



Model :

public class DealModel
   {
       public int DealId { get; set; }

       public int ClientId { get; set; }

       public string DealShareId { get; set; }

       public DealType DealType { get; set; }

       public Status Status { get; set; }

       public SubStatus SubStatus { get; set; }

       public string SDApproverRACF { get; set; }

       public string SDApproverISV { get; set; }

       public DateTime CreatedDate { get; set; }

       public DateTime RespondByDate { get; set; }

       public DateTime? ExpiryDate { get; set; }

       public DateTime? AgreementDate { get; set; }

       public DateTime LastUpdatedDate { get; set; }

       public DateTime? ReviewDate { get; set; }

       public string LastUpdatedBy { get; set; }

       public ClientInformationModel ClientInfoModel { get; set; }

       public DealInformationModel DealInfoModel { get; set; }

       public DealWorkflowModel DealWorkflowModel { get; set; }

       public List<DealAdjustmentModel> DealAdjustments { get; set; }

       public List<DealNoteModel> DealNotes { get; set; }

       public DealModel() { }

       public DealModel(ClientInformationModel clientModel, DealInformationModel dealInfoModel, DealWorkflowModel dealWorkflowModel)
       {
           this.ClientInfoModel = clientModel;

           this.DealInfoModel = dealInfoModel;

           this.DealWorkflowModel = dealWorkflowModel;
       }
   }



Error in Chrome :

Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost/Hermes/Deal/GetInfo/?id=922



Please share your ideas or any answers to resolve this error.

Thanks
Gogulnath

解决方案

.ajax({ url: '/Deal/GetInfo/', type: 'GET', dataType: 'json', data: 'id=' + dealID, success: function (data) { PopulateDealWorkflowDepositsTable(data, 'tableDepositDealEditProduct', true, -1, -1); }, error: function (x, y, z) { alertify.error(genericErrorMessage);


('#loaderSelectProducts').css('display', 'none'); } }); }



Controller :

[System.Web.Mvc.HttpGet]
       public JsonResult GetInfo(string id)
       {
           DealModel dealWorkFlow = this.DealProcessor.GetDeal(Convert.ToInt32(id));
           return Json(dealWorkFlow, JsonRequestBehavior.AllowGet);
       }



Model :

public class DealModel
   {
       public int DealId { get; set; }

       public int ClientId { get; set; }

       public string DealShareId { get; set; }

       public DealType DealType { get; set; }

       public Status Status { get; set; }

       public SubStatus SubStatus { get; set; }

       public string SDApproverRACF { get; set; }

       public string SDApproverISV { get; set; }

       public DateTime CreatedDate { get; set; }

       public DateTime RespondByDate { get; set; }

       public DateTime? ExpiryDate { get; set; }

       public DateTime? AgreementDate { get; set; }

       public DateTime LastUpdatedDate { get; set; }

       public DateTime? ReviewDate { get; set; }

       public string LastUpdatedBy { get; set; }

       public ClientInformationModel ClientInfoModel { get; set; }

       public DealInformationModel DealInfoModel { get; set; }

       public DealWorkflowModel DealWorkflowModel { get; set; }

       public List<DealAdjustmentModel> DealAdjustments { get; set; }

       public List<DealNoteModel> DealNotes { get; set; }

       public DealModel() { }

       public DealModel(ClientInformationModel clientModel, DealInformationModel dealInfoModel, DealWorkflowModel dealWorkflowModel)
       {
           this.ClientInfoModel = clientModel;

           this.DealInfoModel = dealInfoModel;

           this.DealWorkflowModel = dealWorkflowModel;
       }
   }



Error in Chrome :

Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost/Hermes/Deal/GetInfo/?id=922



Please share your ideas or any answers to resolve this error.

Thanks
Gogulnath


You can try the follows, I've changed the data to JSON format:

function EditProduct(action, dealID, dealWorkFlowID) {
    debugger;


这篇关于无法在Ajax Json中加载资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆