AJAX request on the server

Asked

Viewed 148 times

1

AJAX request does not work when on the server...locally works normal... Does anyone have any idea what it might be ?

function SalvarPedido() {

    //Data
    var data = $("#Data").val();

    //Cliente
    var cliente = $("#Cliente").val();

    //Valor
    var valor = $("#Valor").val();

    var token = $('input[name="__RequestVerificationToken"]').val();
    var tokenadr = $('form[action="/Pedido/Create"] input[name="__RequestVerificationToken"]').val();
    var headers = {};
    var headersadr = {};
    headers['__RequestVerificationToken'] = token;
    headersadr['__RequestVerificationToken'] = tokenadr;

    //Gravar
    var url = "/Pedido/Create";

    $.ajax({
        url: url
        , type: "POST"
        , datatype: "json"
        , headers: headersadr
        , data: { Id: 0, Data: data, Cliente: cliente, Valor: valor, __RequestVerificationToken: token }
        , success: function (data) {
            if (data.Resultado > 0) {
                ListarItens(data.Resultado);
            }
        }
    });
}
  • 1

    An error in the console? It could be CORS, in which case it should be an error in the console... This url var url = "/Pedido/Create"; is correct? should not have the server address if it is an external request?

  • but it does not reach nor arrow the values up there in the variables......

  • You can answer my 2 questions? 1: some error on the console? 2: the url is correct?

  • 1 - No 2 - Yes

  • Now only the AJAX request is not working...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.