Error 405: Javascript page redirection leads to Method Not Allowed issue

After receiving the result from the ajax success method, I am facing an issue where the redirection to another page is being blocked and displaying the following error:

Page 405 Method Not Allowed

I am seeking suggestions on how to fix this as I need to successfully redirect to the desired page.

This is what I have attempted so far:

function callinsert(db, tbl, pk, jobj) {
    $.ajax({
        beforeSend: function(xhr) {
            xhr.setRequestHeader("Authorization", "Bearer " + at);
        },
        url: "MYURL/Insert?database=" + db + "&tablename=" + tbl + "&pk=" + pk,
        contentType: 'application/json',
        data: jobj,
        dataType: "json",
        async: false,
        type: "POST",
        success: OnSuccessInsertEmployee,
        /*Create a Function to run the Success Action */
        error: errorAction
    });

}



  function OnSuccessInsertEmployee(data) {
//In this part of the code, I want to redirect to another page
        location.href = "xxxx.html";
    }

Answer №1

It appears that there are two distinct ID names being utilized for the forms, which may be causing issues with redirection upon submission.

To resolve this issue, consider implementing the event.preventDefault() jQuery function within your script to prevent default form submission behavior.

Answer №2

Encountering the HTTP 405 method not allowed error typically indicates that the method being used is available on the server but not permitted for the type of request being made.

To address this issue, ensure that the page is accessible and that either HTTPGet or GET methods are allowed for the requested resource or file. Verify that xxxx.html or any redirected links are also accessible.

If you are using a POST method, confirm that it is returning data successfully. This problem often arises when a POST request is made but the WebAPI is missing the necessary [HttpPost()] attribute on the called Web method.

UPDATE


Check if your IIS / Server allows HTML files to be served. While it is typically allowed by default, some individuals may have removed default handlers for security or performance purposes.

Inspect the Handler Mappings:

Ensure that the StaticFile entry for * exists, is enabled, and is permitted for both GET requests and reading access.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

modifying the appearance of the play button through a JavaScript event without directly altering it

I am currently working on building a music player from scratch using HTML, CSS, and JavaScript only. To store the list of songs, I have created an array named "songs" with details such as song name, file path, and cover image path. let songs = [ {songNa ...

"Exploring the world of RGB color schemes in ThreeJS

I have a collection of points stored in a large string, with newline characters \n separating each point. Each point is saved as x y z r g b, where r g b values fall between 0 and 255. After reading through the ThreeJS documentation, I found a way to ...

.NET site: Retrieve the content of .ascx using jQuery

In an MVC .NET application, utilizing PartialView makes it simple to display the output of an ASCX file. For instance, if we have a Book.ascx file, in the controller we can do: public ActionResult Book(int id) { BookModel model = new BookModel() { book ...

Issue NG0203 encountered during material import attempt

I've been encountering an issue with importing material. Despite using code similar to the examples on material.angular.io, I keep running into the ""inject() must be called from an injection context..." error. My goal is to create a simple table ...

Using an Ajax Post Call to send FormData leads to a Get request instead

Having trouble with sending a simple form via POST method. I load the form content using AJAX: $(function() { var arg = { "operation": "upload", "step": "0" ...

Choosing the Angular5 model

I'm currently working with an Angular5 project that has a <select> element bound to an array of customers. Here's the code snippet: <select class="form-control" [ngModel]="record.customer_id" (ngModelChange)="setCustomer($event)" name=" ...

Enhance your interface with stunning JQuery code snippets

We are in the process of developing a web application that will be fully 2.0 compliant (utilizing AJAX and more). Although I am primarily a rich-client and server-side developer, my knowledge of Javascript is limited to a functional level. However, based ...

Unable to resolve the issue with ExpressPeerServer not being recognized as a function in server.js

I'm facing an issue with the peer.js library in my npm project. I have successfully installed it, but when I try to use it in my server.js file, I get an error saying that peerServer is not a function. const express = require('express'); con ...

Is it appropriate for HTML5 Web Workers to utilize CORS for cross-origin requests?

As I was creating a hosted API that relies on web workers, I encountered an intriguing issue. I am looking for feedback from the community to help me with this. Even though my server has the necessary CORS headers in place to serve the worker JS files and ...

Using values from a select menu in a math calculation without including a decimal point

I am working with a dropdown menu that contains various values... <select id="number1a" onChange="Addition()"> <option value="0" selected>-</option> <option value="10">10</option> <option value="7.5">7.5</optio ...

Exploring the Dynamic Capabilities of AJAX in a CodeIgniter Controller

I am aiming to dynamically parse RSS feeds by utilizing a select list to send a value (id) to the controller via ajax. Subsequently, I aim to parse RSS feeds that correspond to the specific id. The following is a snippet from my Controller home.php : fun ...

Adding elements to a two-dimensional array using AngularJS

How can I assign the value of an input to tasks.name and automatically set status: false when adding a new item to the $scope.tasks array? HTML <input type="text" ng-model="typeTask"> <button ng-click="updateTasks()">Add task</button> ...

Exploring AngularJS 1.x: Understanding the differences between isolated scope and using require with ngModel

Throughout my experience with Angular 1.x, I have always used isolated scope in my directives. However, recently I encountered a directive that solely utilized ngModel. This made me curious about the differences and potential issues when using both methods ...

Creating Functional Tabs Using CSS and JavaScript

I've been experimenting with this code snippet, trying to get it to work better. It's still a work in progress as I'm new to this and have only customized it for my phone so far. The issue can be seen by clicking on the Projects and Today ta ...

Creating an easy-to-update catalog utilizing an external file: A step-by-step guide

I am looking to create a product catalog with 1-4 products in a row, each displayed in a box with details and prices. I would like to be able to generate the catalog easily using an XML/CSV file that can be updated. Can anyone provide guidance on how to ac ...

Tips for crafting interactive Dropdown menus

Visit this link for more information Hello all, I am a beginner in HTML and Javascript and seeking guidance on how to create dynamic dropdown menus similar to the ones on the provided website. I have successfully implemented the source code, but my questi ...

The $scope variable fails to reflect updates in the view following a broadcast event triggered by a

I have been troubleshooting a similar issue and I can't seem to figure out why the update is not reflecting in the view. While I am able to see the scope variable updating in the catch events logs, the changes are not being displayed in the view. For ...

Avoid choosing the menuItem when clicking on the icon within the Material UI select component

I am trying to create a dropdown menu that allows users to delete items. However, when I click on the delete icon within a menu item, the entire menu item gets selected automatically. How can I prevent this default behavior? Here is my code: { dropd ...

The functionality of the JavaScript click function is limited to a single execution

In my dropdown menu, I have a submit function that triggers whenever any children of the dropdown are clicked. However, I now need to exclude a specific li element from this function because it requires inserting a tracking ID in a popup iFrame. The code ...

Angular alert: The configuration object used to initialize Webpack does not conform to the API schema

Recently encountered an error with angular 7 that started popping up today. Unsure of what's causing it. Attempted to update, remove, and reinstall all packages but still unable to resolve the issue. Error: Invalid configuration object. Webpack ini ...