What I have so far is this:

Using the MVC project I am calling controller method with Ajax Script. I just call a function in onclick.

<input id="ButtonGetDetailsAjaxCall" type="button" value="button" onclick="GetDetailsAjaxCall()" />
        <div id="result">
            @Html.Partial("~/Views/Details/GetByApiNumber.cshtml", Model)

Here is my function that actually calls MVC controller Controllers/Details and receives the data back.

        function GetDetailsAjaxCall() {

            var apiNumber = $("#apiselect2").select2('data').text;

            var data = { apinumber: apiNumber };
                url: "/Details/GetByApiNumber",
                type: "GET",
                dataType: "json",
                data: data,
                cache: false,
                success: successFunc,
                error: errorFunc

            function successFunc(data) {
                alert("AJAX SCRIPT : success");

            function errorFunc(jqxhr, textStatus, errorThrown) {
                alert("AJAX SCRIPT : error");


Here is my controller:

    public ActionResult GetByApiNumber(string apinumber)
        MY.Models.Details model = new MY.Models.Details();
        //var model = await this.GetPartalViewDetailsModel(apinumber);

        //return this.View(model);
        return PartialView("~/Views/Details/GetByApiNumber.cshtml", model);

My question is this I need to take this return PartialView("~/Views/Details/GetByApiNumber.cshtml", model); and somehow load it into this div

<div id="result"><div>

More specific: can't quite sure what to do with this return PartialView("~/Views/Details/GetByApiNumber.cshtml", model); meaning how to actually display it using Ajax it errors trying to display it.

Related posts

Recent Viewed