1
I made an ajax request, but it does not call the controller, when debugging javascript never falls in Success and the console appears Error in XML processing.
Controller:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Cadastro(Pedido pedido)
{
if (ModelState.IsValid)
{
var appPedido = new PedidoAplicacao();
appPedido.Salvar(pedido);
return Json(new { Resultado = "Sucesso" });
}
return Json(new { Resultado = pedido }, JsonRequestBehavior.AllowGet);
}
View where I call the js function:
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<a href="#" id="SalvarPedido">Enviar</a>
</div>
</div>
Script
function SalvarPedido() {
var valor = $('#Valor').val();
var cadastro = $('#Data').val();
var url = "/Pedido/Cadastro";
$.ajax({
url: '/Pedidos/Cadastro' ,
type: "POST",
dataType: "json",
contentType: 'application/json; charset=utf-8',
data: { Id: 0, Data: cadastro, Valor: valor },
success: function (data) {
alert('Ok');
}
})
It does not go to the controller. Follow the console image:
Error code generated in the image above:
Error in XML processing: no element found Position: http://localhost:52305/ddc764bf50734262b0fe681dedc10612/browserLinkSignalR/abort? transport=webSockets&connectionToken=Aqaaancmnd8bfderjhoawe%
What is exactly the error? And where does it occur? In the browser console or Visual Studio?
– Jéf Bueno
In the browser console
– Core
And the first question?
– Jéf Bueno
I put the error print in the description.
– Core
Copy the text from the print and paste it in text format into the question, the images here in the company are blocked, I can’t see.
– Guilherme Nascimento
XML parsing error: no element found Position: http://localhost:52305/ddc764bf50734262b0fe681dedc10612/browserLinkSignalR/abort? transport=webSockets&connectionToken=Aqaaancmnd8bfderjhoawe%
– Core