无法在节点js中获取ajax响应?

时间:2014-05-08 08:00:40

标签: javascript node.js

首先,这个问题可能听起来像是重复但我无法找到任何有价值的解决方案。 我的Chatting.html是这样的:

<!DOCTYPE html>
<html>
<head>
<link href="http://fonts.googleapis.com/css?family=Open+Sans Condensed:300italic,300,700" rel="stylesheet" type="text/css">
<link type="text/css" rel="stylesheet" href="../css/stylesheet.css" />

</head>
<body> 
<script>

function urlsend()
{
alert("1");
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari  
xmlhttp=new XMLHttpRequest();
}
 else
 {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
 {
    alert("5");
  alert(xmlhttp.responseText);
  alert("6");
 }

}
alert("2");
xmlhttp.open("Get","../abc.jsp",true);
alert("3");
xmlhttp.send();
alert("4");
}


</script>

<button type="button" onclick="urlsend()">Clickme</button>

<div align="center">
<h4>Online Users</h4>
<ul>

<li onClick="window.open('http://localhost:8000/', '_blank')">John</li>

</ul>
</div>


    <section class="section">

    <!-- These elements are displayed as white info cards in the middle of the screen -->

    <div class="connected">

        <img src="../img/unnamed.jpg" id="creatorImage" />

        <div class="infoConnected">
            <h2>Who are you?</h2>
            <br/>

            <form class="loginForm">
                <input type="text" id="yourName" placeholder="Your nick name" /><br/>
                <input type="text" id="yourEmail" placeholder="Your email address" /><br/>
                <input type="submit" id="yourEnter" value="ENTER" />
            </form>

        </div>

    </div>

    <div class="personinside">

        <img src="../img/unnamed.jpg" id="ownerImage" />

        <div class="infoInside">
            <h2>Chat with <span class="nickname-chat"></span></h2>
            <br/>

            <form class="loginForm">
                <input type="text" id="hisName" placeholder="Your nick name" /><br/>
                <input type="text" id="hisEmail" placeholder="Your email address" /><br/>
                <input type="submit" id="hisEnter" value="CHAT" />
            </form>

        </div>

    </div>

    <div class="invite-textfield">

        <h2>Oops, there are no other people in this chat!</h2>
        <h5>Invite a friend by sending them this URL</h5>

        <div class="link">
            <a title="Invite a friend" href="" id="link"></a>
        </div>

    </div>

    <div class="left">

        <img src="../img/unnamed.jpg" id="leftImage" />

        <div class="info">
            <h2><span class="nickname-left"></span> has left this chat.</h2>
            <h5>Invite somebody else by sending them this page.</h5>
        </div>

    </div>

    <div class="toomanypeople">

        <h2>Oops, you can not join this chat!</h2>
        <h5>There are already two people in it. Would you like to create a                <a title="New Room" href="/create" id="room">new room</a>?</h5>

    </div>

    <div class="nomessages">

        <img src="../img/unnamed.jpg" id="noMessagesImage" />

        <div class="info">
            <h2>You are chatting with <span class="nickname-chat"></span>.</h2>
            <h5>Send them a message from the form below!</h5>
        </div>

    </div>

    <div class="chatscreen">

        <ul class="chats">
            <!-- The chat messages will go here -->
        </ul>

    </div>

</section>

<footer>

    <form id="chatform">

        <textarea id="message" placeholder="Write something.."></textarea>
        <input type="submit" id="submit" value="SEND"/>

    </form>

</footer>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="../js/moment.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="../js/chat.js"></script>

 </body> 
 </html>

当我运行此代码时,它会给出GET http://localhost:8000/chatting/8000/abc 404 (Not Found)。我还在router.js中添加了abc.jsp,但似乎无法弄清楚错误是什么?

0 个答案:

没有答案
相关问题