Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!