Reputation: 212
I've a c# class like below sample code
public class IndexModel : PageModel
{
public JArray Transactions { get; set; }
public IActionResult OnPostTranJarray(int transaction_number, string cardholder)
{
dynamic Trans = GetTransactions(transaction_number,cardholder);
return Trans;
}
}
i just wanted to Make a post call inside the IndexModel Class. I've use these below code in jquery
$.post("https://localhost:7197/Transactions?handler=TranJarray?transaction_number="+transactionNumb+"&cardholder="+cardHolderName, response => {
alert("response",response);
});
$.ajax({
type: "POST",
url: "https://localhost:7197/Transactions?handler=TranJarray?transaction_number="+transactionNumb+"&cardholder="+cardHolderName,
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (data)
{
alert("success");
fnLoadTbl();
}
});
But it's not hitting to the method.. but if i make GET Request to some other method in that class it's working. so let me know if you have any idea. Thanks..
Upvotes: 0
Views: 53
Reputation: 1
You can use data
parameter.
Try this:
var yourUrl= "https://localhost:7197/Transactions"; //pure action
var feed = {
transaction_number: yourNumber,
cardHolderName: yourString
};
$.ajax({
type: "POST",
url: yourUrl,
contentType: "application/json; charset=utf-8",
dataType: "json",
data: feed,
async: true,
cache: false,
success: function (data) {
alert("success");
fnLoadTbl();
}
});
Upvotes: 0