0
I’m having trouble with this request... It’s returning 'not been' on the console. The getValue() method is in the Controller/Homecontroller.Cs
/* JS */
var obj = {
emails: 'teste'
}
var json = JSON.stringify(obj)
$.ajax({
cache: false,
type: 'POST',
url: '/Home/getValue',
data: json,
contentType: 'application/json',
success: (e) => {
console.log('foi')
},
error: (e) => {
console.log('nao foi')
}
})
/* getValue */
[HttpPost]
public ActionResult getValue(string dados) {
return View();
}
I also created a class in Models>Testemodel.Cs
public class TestModel {
public string teste {get; set;}
}
Could you help me? I think the problem might be at the url of ajax... Console error message: POST https://localhost:44355/Home/getValue 500 jquery.min.js:2
Your route is
/Home
whether or not with a capital H?– bfavaretto
I put with a capital H, but I don’t know if the default url to access the Homecontroller is with a capital H.
– Rennan Alves
@Rennanalves remove the
return View();
of its method in theController
. You can only return a View() that exists.– Leandro Angelo