Issue
I tried to call this onget method in .net core using ajax call but this method hitting without parameters
public void OnGet(string id,string refundReason ,int amount)
{
}
I used these 2 ajax call but not passing parameter values
$.ajax({
url: "https://localhost:7197/Transactions/Refund?id="+'20a63762-a6ab-4edb-852b-fd247e9dc247'+"&refundReason="+refundReason+"&amount="+amount,
type: "GET",
dataType: "json",
traditional: true,
contentType: "application/json; charset=utf-8",
success: function (data) {
debugger;
},
});
this one alse tried not passing values to onget method. let me know what changes i've to do. Thanks
$.ajax({
url: "https://localhost:7197/Transactions/,
type: "GET",
data: JSON.stringify({ id: '20a63762-a6ab-4edb-852b-fd247e9dc247',
refundReason:'tt',
amount:"1"
}),
Solution
You should just be able to call it with $.get
and passing the values in the query string. GET calls do not accept body data.
$.get(`https://localhost:7197/Transactions/Refund?id=20a63762-a6ab-4edb-852b-fd247e9dc247&refundReason=${refundReason}&amount=${amount}`, response => {
...
});
Answered By - hawkstrider Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.