0
@model IEnumerable<HitecPoint.BlackBox.Models.SMSReportModal>     
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script>


<script type="text/javascript">

var MyAppUrlSettings =
{

    DistanceReportURL: '@Url.Action("SmsReport", "SmsReport")',

}
</script>


 <script type="text/javascript" >
   $(document).ready(function () {

    alert('hi');
    //Initialize Page
    initializePage();
    //Distance link click
    $("#SearchS_R").click(function () { getDistanceReport(); });

 });
 function initializePage() {
  $("#SmsReport").html('');
   }


  </script>

 <script type="text/javascript">

function getDistanceReport() {

var obj = {};
obj.BBID = "D527";
obj.Interval = 0;

$.ajax({
    type: "POST",
    url: MyAppUrlSettings.DistanceReportURL,
    data: "{obj:" + JSON.stringify(obj) + "}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
        if (data.Html) {
            $("#SmsReport").html(data.Html);
        }
        else {
            $("#SmsReport").html("<p style='color: #AFAEAE; font-family: status-bar; font-size: 16px; font-weight: bold; margin: 30%;'> No Data available </p>");
        }
        $("#overlay").fadeOut();
        $("#loading").hide();
    },
    error: function (request, status, error) {
        alert(error);
        $("#overlay").fadeOut();
        $("#loading").hide();
    }
});
}

and my function is below. I have made a class of SMSReportModal in which i have declared all properties of object

public ActionResult SmsReport(SMSReportModal _SMRobj)
    {
        string k = _SMRobj.BBID;
        return Json(true);
    }

I am using razor in Mvc .I want to pass data object to function using ajax, but function returns me null value of object.What mistake I have done.Please help

2
  • Which function returns null ? Commented Dec 18, 2013 at 10:01
  • Your data attribute should be data: { obj: JSON.stringify(obj) } for starters Commented Dec 18, 2013 at 10:03

1 Answer 1

1

Try this

....

data: {_SMRobj:JSON.stringify(obj)},

....

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

2 Comments

Cosset I have implemented your code but now i get new error in pop window which show error "Internal Server error". i cannot understand.please help
Insert breakpoint at the beginning of SmsReport action and debug.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.