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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:45:52+00:00 2026-05-21T11:45:52+00:00

Having some problems with getting some ajax script to work. Using this as the

  • 0

Having some problems with getting some ajax script to work.
Using this as the html page:

<html>
    <head>
        <script type="text/javascript" src="scripts\main.js"></script>
        <link rel="stylesheet" type="text/css" href="css\mainStyle.css" />
    </head>
    <body onload="onloadHandler();">
        <canvas id="canvas" style="background-color:#ddd">
            Sorry, your browser does not support the canvas element.
        </canvas>
    </body>
</html>

The script:

function onloadHandler()
{   
    canvasItem = document.getElementById('canvas');

    canvasItem.addEventListener('mousedown', mousedownEventHandler, false);
    canvasItem.addEventListener('mousemove', mousemoveEventHandler, false);

    callService("http://www.xul.fr/somefile.xml");
    //  callService("http://allcodecorner.com/index.html");
//  callService("http://stackoverflow.com");
//  callService("http://www.w3schools.com/ajax/ajax_info.txt");
    setTimeout("redraw()", 5);
}

function callService(serviceName)
{
    var xmlhttp;
    if(window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();

    } else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if(xmlhttp.readyState == 0)
        {
            alert('not initialized');
        } else if (xmlhttp.readyState == 1)
        {
            alert('connection established');
        } else if (xmlhttp.readyState == 3)
        {
            alert('processing request');
        } else if (xmlhttp.readyState == 4)
        {
            alert('ready!');
        }

        if(xmlhttp.readyState==4)
        {
            if(xmlhttp.status==200)
            {
                alert(xmlhttp.responseText);
            } else {
                alert('Failed: ' + xmlhttp.responseText + ", status: " + xmlhttp.status);
            }
        }
    }
    alert(serviceName);
    xmlhttp.open("POST",serviceName,true);
    xmlhttp.send(null);
}

No matter what address I put in, I get the messages
‘connection established’
‘ready’
‘Failed: , status: 0’.

I’ve tried on firefox and chrome, have tried running it locally and hosted, nothing seems to work. I always get a readyState of 4 and status of 0.
Any ideas? I’ve tried multiple sites to connect to, same thing every time.
Have also tried with GET, setting some headers, same result. Pretty much tried every example I could find, with no luck

  • 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-05-21T11:45:53+00:00Added an answer on May 21, 2026 at 11:45 am

    You seem to be trying to make an Ajax request to a remote location, which is impossible due to the Same Origin Policy.

    Not sure whether there’s a fix: If you control the remote location, you can make it send JSONP instead. If that’s not possible, you’re going to have to use a server-side proxy.

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

Sidebar

Related Questions

I'm having some problems with a datagridview element I'm using in VS2008. This DataGridView
I am having problems getting validation to work for a form built using Zend_Form.
I'm having some problems getting my object to gracefully fail out if an invalid
I having trouble getting append() to work in safari for some reason, but it
Having some problems initialising a google map using geocoding. First issue is with any
I am having some problems in using CryptoStream when I want to encrypt a
I'm having some problems with this jQuery....I'm new to it. It looks like it's
I'm having a problem getting this functionality to work. Situation is: User Drags an
I'm having some difficulties getting my head around Rails' general application layout. Basically, I
I'm having nice first days using Yii but have some troubles with getting things

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.