Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Infragistics Infragistics.Web.Mvc 2022 Ajax call issue
posted

Hi Team

I the scenario tried different ways not working. Can you check I am attaching  code scenario.

scenario: if my payload has list all post ajax calls are 500 error

Action

=======================

[GridDataSourceAction]
[HttpPost]
public ActionResult PostDataMethod3(Product Param1, string Param2, string Param3)
{
try
{
List<Product> products = new List<Product>();

products.Add(new Product { ProductID = 1, Name = "Product 1", ProductNumber = "12345" });
products.Add(new Product { ProductID = 2, Name = "Product 2", ProductNumber = "12346" });
products.Add(new Product { ProductID = 3, Name = "Product 3", ProductNumber = "12347" });
products.Add(new Product { ProductID = 4, Name = "Product 4", ProductNumber = "12348" });
products.Add(new Product { ProductID = 5, Name = "Product 5", ProductNumber = "12349" });

return View(products.AsQueryable());
}
catch (Exception ex)
{
string error = ex.Message;
return null;
}

}

Ajax

=================================

//json2
var appJson1 = {
"Param1": { "ProductID": 1, "Name": "test product", "ProductNumber": "P123", "Locations": [{ "Address": "Address1" }, { "Address": "Address2" }]}, "Param2": "Param2", "Param3": "Param3" };

$('#postData3').click(function (e) {
e.preventDefault();

$.ajax({
url: '@(Url.Action("PostDataMethod3"))',
type: 'POST',
traditional: true,
contentType: "application/json",
dataType: "json",
data: JSON.stringify(appJson1),
success: function (response) {
alert('Succcess');
$('#grid').igGrid({ dataSource: response }).igGrid("dataBind");
},
error: function (xhr, ajaxOptions, thrownError) {
alert('Failure - ' + xhr.responseText);
$('#grid').igGrid({ dataSource: null }).igGrid("dataBind");
}
});
});

View Model

========================================

public class Product
{
public int ProductID { get; set; }
public string Name { get; set; }
public string ProductNumber { get; set; }

public List<ProductLocations> Locations { get; set; }
}

public class ProductLocations
{
public string Address { get; set; }
}

Error screen

0184.2022infragisticerror.igGridQueryStringToJson.zip

Parents
No Data
Reply
  • 60
    Offline posted

    Hello Anitha, 

     

    I noticed that the same question is asked in this forum thread where I have already provided an answer. 

     

    Please keep in mind that according to our support policy we handle single support case/forum thread per query. This helps us ensure that all your issues are addressed correctly. 

    I will continue assisting you via the forum thread so that other members of our community may benefit if they encounter the same situation.  

     

    Thank you for using Infragistics components. 

    Regards,
    Aleksandar Atanasov,

    Infragistics.

Children
No Data