Trying to figure out 405 Method Not allowed error

Hi All,

I have a login HTML form as shown below:

<div id="wrap">
 
            <div id="window" caption="Login">
                <div>
                    
                        <table>
                            <tr>
                                <td>Username:</td>
                                <td><input style="width: 150px;" type="text" name="user" id = "username" /></td>
                            </tr>
                            <tr>
                                <td>Password:</td>
                                <td><input style="width: 150px;" type="password" name="password" id = "password" /></td>
                            </tr>
                            <tr>
                                <td colspan="2" align="right" valign="bottom">
                                    
                                    <input type="button" id="submit" value="Login" />
                                </td>
                            </tr>
                        </table>
                    
                </div>
            </div>

I am making a POST Ajax call like the following:


jQuery(document).ready(function () {

           
            var loginUrl = "/MyWebApp/authenticate"

            $( "#submit" ).click(function(e) {
               
                 e.preventDefault();

                 var userNAME = $("#username").val();
                 var passWord = $("#password").val();

                 var ajaxRequest = jQuery.ajax({
                    
                    data: {
                        username: userNAME,
                        password: passWord 
                    },
                    dataType: "json",
                    method: "POST",
                    url: loginUrl
                })
                .done(function (data_, textStatus_, jqXHR_) {

                 // Some code here   
                 
                })

                .fail(function (jqXHR_, textStatus_, errorThrown_) {
                    alert("Hitting the Fail function : Error in authenticate webservice: " + errorThrown_);
                    return false;
                });

            });

When I type on my browser https://mydomainname.com/ , I see the alert window mentioned in the fail function above with the message : Hitting the Fail function : Error in authenticate webservice: Method Not Allowed. The same I see in the browser console as well like the following:

POST https://mydomainname.com/MyWebApp/authenticate 405 (Method Not Allowed)

Could anyone please tell me what’s wrong I am doing? Is it SSL related issue? Or is there a way I can stop the prepending of URL https://mydomainname.com and can have just absolute path displayed on browser console like the following POST /MyWebApp/authenticate

With ajax function you are try to connect via server to another url file.I think that is CORS issue that prevents you to post.
Try only with method: "GET" and let us know if this work.

Actually every thing is on the same server. So it shouldn’t be CORS I guess. Basically, the URL https://mydomainname.com is served by Apache which has SSL certificate installed and webservices are in tomcat which doesn’t have the certificate. Can this be issue?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.