It seems like I have a little mistake in my code. But I cant find it.

So, I'm calling an Action in my Controller from my ajax function.

var serviceURL = '/Vm/GetVMInformation';

    type: "GET",
    url: serviceURL,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (result) {
        alert("This Works fine");
        $("#testDiv").html(result); // Display the partial View in this div
    error: function (XMLHttpRequest, textStatus, errorThrown) {

My Action then returns a partial view and an list object.

public ActionResult GetVMInformation()
    List<VmInfo> VMListArray = new List<VmInfo>();
    ... Code ...
    return PartialView("_List", VmList);

The Action gets called and the partial View works. I tested it. So the problem is, my ajax function isnt successful. So it throws an error. When I alert the error I just get "Internal Server Error".

Does anyone see my mistake?

Note: My partial view. Not sure if its important

<!--This partial View is just for testing the ajax function-->

@model IsolutionsAzureManager.Models.VmData



So I changed the return type of my function (which has now the type JsonResult) to Json

    JavaScriptSerializer jss = new JavaScriptSerializer();

    string output = jss.Serialize(VmList);
    return Json("_List", output);

The good news: The ajax call is now successful. The bad news: I still can't display my partial View. The return value (result) is just [object, Object]

    success: function (result) {

Related posts

Recent Viewed