Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
JavaScript
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 :
C#
[System.Web.Mvc.HttpGet]
       public JsonResult GetInfo(string id)
       {
           DealModel dealWorkFlow = this.DealProcessor.GetDeal(Convert.ToInt32(id));
           return Json(dealWorkFlow, JsonRequestBehavior.AllowGet);
       }


Model :
C++
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
Posted

1 solution

You can try the follows, I've changed the data to JSON format:
JavaScript
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');
        }
    });
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900