1

I got jquery ajax request on client side and asp mvc on server side. I send this to the server enter image description here But I didn't get temperatureRanges enter image description here Do somebody know why?

ajax-code:

$.ajax({
            type: 'POST',
            async: false,
            url: "/PVTMethods/StandartModelResult",
            data: JSON.stringify(dataForSend),           
            async: true,
            success: function(data) {
                //TODO Реализовать обработку результата
            },
            error: function(data) {
                console.log("Error" + data);
            },
            dataType: "json",
            contentType: "application/json; charset=utf-8",
        });

Model on server:

 public class DefaultRanges {
        public virtual double Start { get; set; } //начало отрезка
        public virtual double End { get; set; } //конец отрезка
        public virtual double Samples { get; set; } //шаги
    }

public class TemperatureDefaultRanges:DefaultRanges {}
public struct InputDataModel
    {
        /// <summary> решаемая задача </summary>
        public Tasks task;
        /// <summary>  данные по давлению </summary>
        public PressureDefaultRanges pressureRanges;
        /// <summary>  данные по температуре </summary>
        public TemperatureDefaultRanges temperatureRanges;
        ////в pvt настройки по ctrl+H - ranges для отдельно взятого графика
       /// <summary>  данные по температуре </summary>
        public PlotRanges currentTaskPlotRanges;
        public double plotConstant; //либо GOR либо Pressure (зависит от задачи)

    }
4
  • whats JSON.stringify(dataForSend) print ? Commented Mar 30, 2015 at 5:09
  • 1
    Change your fields to properties (add getters and setters) so the DefaultModelBinder can set them. Commented Mar 30, 2015 at 5:24
  • @user1428716 "{"method":"eStanding","model":{"task":"ePb","temperatureRanges":{"Start":200,"End":1000,"Samples":30}},"constants":{"ProducedGOR":500,"OilGravity":35,"SeparatorGasGravity":0.7,"StockTankOilGravity":0.84956,"WaterSalinity":20}}" Commented Mar 30, 2015 at 6:02
  • @StephenMuecke post answer please Commented Mar 30, 2015 at 6:18

1 Answer 1

1

You need to make the fields in InputDataModel properties by adding { get; set; } so the the DefaultModelBinder can set the value of the properties.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.