Convert Javascript object to C# object -
i'm setting facebook canvas payments , requires callback when order successful. have code below , i'm using ajax pass callback data method can it. don't know set parameter method can pass data correctly.
fb.ui(obj, function (data) { $.ajax({ type: "get", datatype: "json", contenttype: "application/json", url: "/home/finishorder", data: myjsobject, async: true }); }); public class orderdetails { public string payment_id { get; set; } public decimal amount { get; set; } public string currency { get; set; } public int quantity { get; set; } public string request_id { get; set; } public string status { get; set; } public string signed_request { get; set; } } public void finishorder(orderdetails orderdetails) { sendemail.sendemail(orderdetails.amount.tostring()); }
close, try this:
fb.ui(obj, function (data) { $.ajax({ type: "get", datatype: "json", content-type: "application/json", url: "/home/finishorder", data: myjsobject, success: function(data) { alert('success'); } }); }); public class orderdetails { public string payment_id { get; set; } public decimal amount { get; set; } public string currency { get; set; } public int quantity { get; set; } public string request_id { get; set; } public string status { get; set; } public string signed_request { get; set; } } public actionresult finishorder(orderdetails orderdetails) { sendemail.sendemail(orderdetails.amount.tostring()); return json(new { result = "e-mail sent" }, jsonbehavior.allowget); }
note: js object must have same property names c# one.
Comments
Post a Comment