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

282
Vistas
Calling API through Ajax - getting 403 error

I am calling an url using ajax - but when it is called I am getting response HTTP/1.1 403

below is my calling code

function callApi() {
      var xmlhttp = new XMLHttpRequest();
       xmlhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
        document.getElementById("txtHint1").innerHTML = this.responseText;
         }
     }
       xmlhttp.open("GET", "http://103.240.91.110/GENCLASS/checkApi.do? 
$95599&99&3456790&09012020152103*", true);
      xmlhttp.send();
   }

Below is the server side method who is sending the response

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

    ActionErrors errors = new ActionErrors();
    ActionForward forward = new ActionForward(); // return value
    ApiForm apiForm = (ApiForm)form;

    try {
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods","GET, OPTIONS, HEAD, PUT, POST");
        
        // send back response
        System.out.println("true");
        
    }catch(Exception e){
        errors.add(ActionErrors.GLOBAL_ERROR, new org.apache.struts.action.ActionError("load.error.unknown"));
        //log.error("Critical Error " + e);
    }
    if (!errors.isEmpty()) {
        saveErrors(request, errors);
        forward = mapping.findForward("failure");
    } else {
        forward = mapping.findForward("success");
    }
    return (forward);
}

Whenever I am calling the URL I am getting response HTTP/1.1 403 Note that It is working perfectly when I am requesting through browser

I am using tomcat 8.5 on windows on server (called resource) Any assistance will be appreciated

over 4 years ago · Santiago Trujillo
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