Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
How we can call python POST request API from JQuery Ajax It showing CORS policy error

I have python API which is POST request,

http://192.168.2.25:8059/calculation

In Postman it return response like (Expected output should be same as like below)

[
    {
        "Indexs_q1": [ 13,14,15,],
        "Points_q1": [ 69,72,75,]
    }
]

In my case I am calling this API which is already in json format like ,

api_Object = {
    "avg":[30,33,36],
    "data":[10,20,30],
    "Avg_xbar":66,
    "ucl":116.776,
    "lcl":15.224
}

$.ajax({
    url: "http://192.168.2.25:8059/calculation",
    type: "POST",
    data: api_Object,
    //data: JSON.stringify(api_Object),
    dataType: "json",
    success: function (response)
    {
        var resp = JSON.parse(response);
        alert(resp.status);
    },
    error: function (xhr, status) {
           alert("error");
    }
});

NOTE : It showing error - Access to XMLHttpRequest at 'http://192.168.2.25:8059/calculation' from origin 'http://localhost:65047' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

After facing lots of issue finally I got an solution,

    $.ajax({
        url: "http://192.168.2.25:8059/calculation",
        type: 'POST',
        dataType: 'json',
        cors: true,
        contentType: 'application/json;charset=UTF-8',
        secure: true,
        data: api_Object,
        headers: {
            'Access-Control-Allow-Origin': '*',
        },
        success: function (data, status, xhr) {
            console.log('success');
        },
        error: function (jqXhr, textStatus, errorMessage) {
            console.log('error');
        }

    })
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda