Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Ajax call to execute WebApi method that is returning complex object.

$
0
0

I have a Ajax call to a WebApi method. My Call is looks like this:

function CalculateAmortizationScheduleAPI()
    {

        $.ajax({
            url: 'http://localhost:62815/v1/APR/Calculate',
            type: 'POST',
            dataType: 'json',
                data: {
                    "LoanAmount": 200000,"Costs": 100,"Term": 15,"Rate": 2.2,"RateType": 2,"Points": 1,"MIRate": 2.2,"UFMIRate": 2,"FixedTerm": 5,"FirstPaymentDate": "10/10/2017","RateChangeDate": "10/10/2018","AdjustTerm": 2,"IndexRate": 2,"Margin": 2,"AdjustmentCapFirst": 2,"AdjustmentCap": 2,"AdjustmentCapLifetime": 2,"EstimatedPropertyValue": 2,"CancelMIPMonths": 2,"CancelMIPLTV": 2,"AdditionalPricipalPayment": 2,"ConstantPaymentValue": 2
                },
                success: function (data) {
                    alert("success");

            },
            error: function () {
                alert("Error");
            },
        });
    }

And this is my WebApi method that Ajax call successfully hit when I put the breakpoints and also the return value has value as a object.

[HttpPost]publicDictionary<int,AmItem>Calculate([FromBody]AmArguments
     lAmArguments){.....returnAmSchedule;}

The problem is that even though the Ajax call hit the method but the Success method is not executing and the Error Alert will appear in the screen, Also I don't know how to capture return value that is complex object (AmSchedule)


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>