1

i know this questions asked several times, and i am referring all these post, even after that also not able to solve my problem. I have created a html page for client server communication. Here is the code

<!DOCTYPE html>
<html>
    <head>
        <title>Sandbox</title>

        <script type="text/javascript">

            function log (text) {
                document.getElementById("contents").innerHTML = document.getElementById("contents").innerHTML + "<br />" + text;
            }

            function ready() {
                log("Ready.");
                var xmlhttp = new XMLHttpRequest();

                xmlhttp.onreadystatechange = function () {
                    log("State: " + xmlhttp.readyState + ", Status: " + xmlhttp.status
+ ", Statustext: " + xmlhttp.responseText);
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                        log("CSV Content:");
                        log(xmlhttp.responseText);
                    }
                };

                log("Open.");
                xmlhttp.open("GET", "http://10.5.13.142/iptvservice.xml", false);
                log("Send.");
                xmlhttp.send(null);
                log("Sent.");
                window.removeEventListener('DOMContentLoaded', ready, false);
            }

            window.addEventListener('DOMContentLoaded', ready, false);
        </script>

    </head>
    <body>
        <div id="contents">Loading.</div>
    </body>
</html>

server is a Apache server.I am running this page on a same machine where server installed. On Mozilla status code is 0 and on It hanged on loading. I am not getting what is the problem. i have read that you don't need to set the permission on manifest.json if you are on the same domain. Then where i am getting wrong. Please help.

Edit: Actually my requirement is to run this code on android using phonegap. So i want to do using java script. So anybody can suggest using xmlhttprequest how to create client server connection.

Manisha Khare
  • 155
  • 3
  • 15
  • 1
    please check this link. this may help you http://stackoverflow.com/questions/5005960/xmlhttprequest-status-0-responsetext-is-empty – knowledgeseeker Jan 15 '13 at 09:21

1 Answers1

0

sorry, but just now i got this link

XMLHttpRequest Fails On Same Domain

but in my case Apache server giving xml page. So where i should put my script.and this is just for testing purpose i am using same machine, but after that i need to run same page on different machine. Then what would be the solution. sorry i am asking very simple question, but required little help.

Edit: just for information. I did change according to the link

http://www.skill-guru.com/blog/2011/02/04/adding-access-control-allow-origin-to-server-for-cross-domain-scripting/

and then ran on google chrome, it worked, but it still not working on firefox. Anyways, atleast my code and server installation is proper.

Community
  • 1
  • 1
Manisha Khare
  • 155
  • 3
  • 15