i acan use ajax and api action in one project and send data and update data correctly.
but when i want to send data from ajax in my project to api action in my another project,the api action dont work!
$.ajax({
type: "post",
url: urll, error: function () { alert("errore") },
data: {id: 4},
success: function (dataa) {
alert("ok");
var x = JSON.stringify(dataa, null, '\t');
var dataaa = $.parseJSON(x); alert(dataaa.price);
dataa.price -= 1.02;
var url2 = 'https://localhost:44337/api/apiialbums/PutAlbum';
$.ajax({
type: "PUt",
url: url2,
data: {album: dataa },
success: function (dataaz) {
alert("updated");
alert(dataaz.price);
var x2 = JSON.stringify(dataaz, null, '\t');
alert(x2);
},
error: function () {
alert("error in update..");
}
})
}
});
and my api [httpput]action:
[HttpPut]
public async Task<ActionResult<Album>> PutAlbum([FromBody]Album album)
{
_context.Entry(album).State = EntityState.Modified;
await _context.SaveChangesAsync(); return album;
}
when i breakpoint in api action,
I understand that the program does not refer to the action
What I have tried:
I searched the internet a lot but I could not find the reason, please help me to solve this problem as soon as possible