1

I am getting the following error when I am trying to run this code on the browser. "Error response Error code: 501 Message: Unsupported method ('POST'). Error code explanation: 501 - Server does not support this operation."

The following errors were in the browser console:

"1. Failed to load resource: the server responded with a status of 404 (File not found)

 'http://localhost:8002/js/jquery-1.3.2.min.js'
  1. Resource interpreted as Script but transferred with MIME type text/plain: pquery-0.0.1.js:1
  2. Failed to load resource http://mdsad.com/p.js?v=1372783767755 undefined login.html:61 POST

    http://localhost:8002/login.html 501 (Unsupported method ('POST')) login.html:1
    

    Resource interpreted as Script but transferred with MIME type text/plain: pquery-0.0.1.js:1

  3. GET http://mdsad.com/p.js?v=1372783801500 download.js:33"

The login of users via stackmob also fails. I get a 'Failure' alert message. Here is the code:

    <html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/stackmob-js-0.9.1-bundled-min.js"></script>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login Form</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
    $(".username").focus(function() {
        $(".user-icon").css("left","-48px");
    });
    $(".username").blur(function() {
        $(".user-icon").css("left","0px");
    });
    $(".password").focus(function() {
        $(".pass-icon").css("left","-48px");
    });
    $(".password").blur(function() {
        $(".pass-icon").css("left","0px");
    });
    });
</script>
<script type="text/javascript">
function nextpage(form){
StackMob.init({
publicKey:"my_key",apiVersion:0
});
var u=document.getElementById('username').value;
var p=document.getElementById('password').value;
var user = new StackMob.User({ username: u, password: p});
user.login(false, {
  success: function(model, result, options) {
  alert("Success");
  StackMob.isUserLoggedIn(form.username.value, {
  yes: function() { alert("Yes"); },
  no: function() { 
  alert("No");}
});
},
error: function(model, result, options) {
  console.log(result); 
alert("Failure");//or print out the error
} }); };
</script>
</head>
<body>
<div id="wrapper">
    <div class="user-icon"></div>
    <div class="pass-icon"></div>
<form name="login-form" class="login-form" action="" method="post">
    <div class="header">
<h1>Login Form</h1>
<span>Fill in the details</span>
</div>
    <div class="content">
<input id="username" name="username" type="text" class="input username" value="Username" onfocus="this.value=''" />
<input id="password" name="password" type="password" class="input password" value="Password" onfocus="this.value=''" />
</div>
<div class="footer">
<input type="submit" name="submit" value="Login" class="button" onclick="nextpage(this.form)"/>
<input type="submit" name="submit" value="Register" class="register" />
</div>
</form>
</div>
<div class="gradient"></div>
</body>
</html>

However, I am sure about the stackmob part because it worked well in a simple code of mine. Here is the working simple code:

    <html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/stackmob-js-0.9.1-bundled-min.js"></script>
<script type="text/javascript">
function nextpage(form){
StackMob.init({publicKey:"my_key",apiVersion:0});
var u=document.getElementById('username').value;
var p=document.getElementById('password').value;
user.login(false, {
  success: function(model, result, options) {
  alert("Success");
  StackMob.isUserLoggedIn(form.username.value, {
  yes: function() { alert("Yes"); },
  no: function() { 
  alert("No"); 
}
});
},
  error: function(model, result, options) {
    console.log(result); 
    alert("Failure");//or print out the error
}
});
};
</script>
</head>
<body>
<form>
<table>
<tr><td>Username</td><td><input id="username" type="text"></td></tr>
<tr><td>Password</td><td><input id="password" type="text"></td></tr>
<tr><input type="button" value="LOGIN" onclick="nextpage(this.form)"></tr>
</table>
</form>
</body>
</html>

Can someone please tell me where am I going wrong?

Ice
  • 35
  • 1
  • 1
  • 6
  • You can ignore the MIME type warning - these are common. Have you checked to see if that file exists? – Christian Stewart Jul 02 '13 at 17:02
  • @ChristianStewart : yeah that doesn't come everytime. i guess the basic problem is that the stackmob login is failing everytime and i am getting post and get errors. – Ice Jul 02 '13 at 20:49

2 Answers2

10

You are running a local server on port 8802 but the javascript file "jquery-1.3.2.min.js" is not at the location specified, hence the 404 error.

The 501 error is because the server you are using (presumably something like simpleHTTPServer) doesn't support POST requests.

To resolve that error you need to use a server that supports POST requests (e.g. Apache, IIS).

Fraser
  • 15,275
  • 8
  • 53
  • 104
  • Okay I have removed that line, i have removed the 404 error now. Aout the post and get, I thought so about the server at first. But I am running both the first and the second programs on python server. The second one yields results whereas the 1st one does not. – Ice Jul 02 '13 at 20:48
  • Looking at your code, you don't define a user `var user = new StackMob.User({ username: u, password: p});` in the working code as you do in the first example... – Fraser Jul 03 '13 at 17:28
  • that was a typing mistake. i missed that line. actually the second code is working. the first one is not. – Ice Jul 04 '13 at 19:01
1

Your importing Jquery twice, and two different versions, this could add all sorts of strange issues assuming the 404 is inaccurate.

Remove this line:

<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>

If nothing else it will clear the 404

PA.
  • 28,486
  • 9
  • 71
  • 95
lees2bytes
  • 296
  • 2
  • 9