Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7939485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:06:53+00:00 2026-06-03T23:06:53+00:00

I am trying to send a post request through ajax to another domain and

  • 0

I am trying to send a post request through ajax to another domain and get a json response. The server is situated in my company premise and through the logs, I can see that it is sending response with a json.

Following is a sample of my tries:

1)

function makeRequest(strURL){
    $.get(strURL+"?callback=rest.draw_table_dyn", "{}", 
    function(resp){
        rest.draw_table_dyn(resp);
    });
}

2)

xmlhttpPost : function(strURL) {
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest) {
    self.xmlHttpReq = new XMLHttpRequest();
    }
else if (window.ActiveXObject) {
    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader("Content-Type", "application/json");
self.xmlHttpReq.onreadystatechange = function() {
    rest.draw_table_dyn(self.xmlHttpReq.responseText);
}
self.xmlHttpReq.send(null);
}

However, following are the problems I encounter:

1) Always the server is hit with a “OPTIONS” request rather than a “GET” or “POST” request. I understood from this link(http://engin.bzzzt.biz/2010/01/25/cross-domain-xhr-access-control-preflight/) that it is a preflight request as per the standards.

But is it possible for me to make a POST request? I tried using $.post, $.ajax or even $.get, but to no avail.

2) The response data is empty. I require the data to populate the page with items. Is there a way to read the json? Currently I am getting only an empty string with the return status a 0.

I tried xmlHttpRequest, $.ajax, $.get and $.post to send the request and receive the json to no avail.

I read here(http://stackoverflow.com/questions/4221458/how-to-make-a-jsonp-call-to-an-api-using-jquery) about keeping the script in the tag. This also didn’t worked for me. Any ideas what I am doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:06:55+00:00Added an answer on June 3, 2026 at 11:06 pm

    Currently, the only way to POST to another origin via Ajax is if the server responds with an appropriate CORS Allow-* header:

    Access-Control-Allow-Origin: your.origin
    

    Without such a header, the request will be refused by the browser due to the Same-Origin Policy.

    In your 1st example, it appears you’re attempting to use JSONP (?callback=...). Such requests are strictly limited to GET as they are made by appending a new <script> element to the page rather than via XMLHttpRequest:

    <script src="http://remote.origin/resource?callback=rest.draw_table_dyn"></script>
    

    CORS is also limited in browser support to those with either XMLHttpRequest Level 2 or XDomainRequest (IE8/9).

    Beyond that, you’re limited to having to create a server-side proxy that mediates between the browser and the remote server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send the xml to another webserver through Restclient's http POST request.This
I'm trying to send data through a POST request from a node.js server to
I'm trying to send a post request to Parse: https://parse.com/docs/rest#objects-creating . Can't get it
I am trying to send a AJAX request to the server when a user
I have a problem when trying to send a POST request. The sending method
Trying to find a way to send a POST HTTPS request from Python to
I am trying to send a gzip ed multipart POST to a Tomcat server
Trying to send POST request on click event using jQuery with no luck. Here
While trying to send a POST request via xmlhttp.open(POST, url, true) (javascript) to the
I am trying to send a POST request to Drupal's Services module & JSON_Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.