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 8739899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:02:12+00:00 2026-06-13T11:02:12+00:00

I started learning AJAX recently and am trying a very simple project which involves

  • 0

I started learning AJAX recently and am trying a very simple project which involves capturing some form data and sending it to two servers.

The first server is the one which hosts the website and server side php handling. This worls fine

The second server is a python basic http server which handles only the POST operation request send from AJAX. This functionality works but is a bit weird.

Let me explain

Here is my AJAX code which is absolutely straight forward.

function xml_http_post(url, data) {
    var req = false;
    try {
        // Firefox, Opera 8.0+, Safari
        req = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }

    req.onreadystatechange = function() {
        if (req.readyState == 4) {
    //        callback(req);

        }
    }

    req.open("POST", url, true);
    req.setRequestHeader("Content-type","text/plain");
    req.send(data);
}  

Since I do not intend to send back any response , my callback function on ready state change is empty.

But when I execute this code ( triggered by onclick on a button) , the POST doesnt work and server doesnt seem to receive anything.

But the most surprising thing is that if I keep a breakpoint at req.open( ) and then do a manual step execution then it works always. Which means , I guess that there is some timing issue which needs to be resolved.

It works fine without breakpoints if the third parameter “async” is set to false but that is anyway undesirable so I want to make it work with async = true.

Any help would be greatly appreciated.

Thanks
Shyam

  • 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-13T11:02:13+00:00Added an answer on June 13, 2026 at 11:02 am

    As I figured out, the form page was getting unloaded by a php script which was invoked as a action of the form b the first server. This resulted in the javascript code being partially or not executed.

    So I figured out that sync XHR is the only way for my.

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

Sidebar

Related Questions

hi everyone im just started learning ajax. im trying to get the return value
I've just started learning Sencha Touch. Trying to build a simple news reader app.
1) A while ago I’ve started learning Asp.Net, but then I’ve heard that Ajax
I have just started learning python version 3 and trying to create a file
I have only started learning python recently. I would still be considered a beginner.
sorry but Im unable to understand these example. I started learning ajax right from
I started learning jQuery just yesterday, and I like it very much. And now
I've just recently started looking into the details of which events fire when in
I am working on website using ajax and C#. I started learning these languages
I started learning programming 4 months ago. So far I already know some javascript(and

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.