How can I prevent the Firefox pop-up stating "This web page is being redirected to a new location" from appearing with every requestPromise AJAX call?

My web app has extensive AJAX functionality. While initially working fine in my tests, today I encountered an issue with Firefox on both Mac and IE where a pop-up message "This web page is being redirected to a new location" appears for every PUT and DELETE ajax call, causing chaos on the page. Surprisingly, this pop-up does not show up for GET calls.

The PUT and DELETE requests are structured using Angular Promises, while the GET request uses a standard $.http call.

Here's the code snippet for the GET request that doesn't trigger the pop-up:

 $http({
                method: 'GET',
                url: $scope.faveURL
            }).success(function (data, status, headers, config) {
                if (data === "false") {
                    $scope.faveempty = true;
                    $scope.faveloading = false;
                } else {
                    $scope.favourites = data;
                    $scope.faveloading = false;
                }
            });

And here's the code snippet for the PUT and DELETE requests that do trigger the pop-up:

if (food.favourite === true) {
                requestPromise = $http.put($scope.URL).then(function () {
                    $scope.favourites.push(food);
                    $scope.faveempty = false;
                    food.loading = "none";
                    change = $scope.favouriteChange(food);
                });

            } else if (food.favourite === false) {
                requestPromise =  $http({
                    method: 'DELETE',
                    url: $scope.URL
                }).then(function () {
                    $scope.favourites.splice($scope.favourites.indexOf(food), 1);
                    if ($scope.favourites.length < 1) {
                        $scope.faveempty = true;
                    }
                    food.loading = "none";
                    change = $scope.favouriteChange(food);
                });
            }

Has anyone else encountered similar issues with requestPromise for Ajax calls? If so, have you found any solutions?


UPDATE:

Upon inspecting the Network traffic, it turns out that the pop-up only occurs for AJAX responses that involve a redirection. For example, no pop-up for this response:

[15:09:58.742] GET http://redacted/api/ext/group/35/ [HTTP/1.1 200 OK 381ms]

But there is a pop-up for this response:

[15:03:25.036] PUT http://redacted/api/ext/favorite/713 [HTTP/1.0 301 TYPO3 RealURL redirect 126ms]

It seems to be related to how Typo3 services handle PUT and DELETE methods, triggering the Firefox warning dialog.

Answer №1

While this solution may not directly apply to your specific issue, I encountered a similar problem which turned out to be caused by using the incorrect request type. This information could benefit others facing similar issues.

It's important to note that I was utilizing jQuery in my code.

Here is the original piece of code:

      $.ajax({
        url: link,
        type: 'json',
        success: function(html) {
          return _this.ajaxLoadIn(html);
        },
        error: function(e) {
          return alert('Sorry, something went wrong, please try again');
        }
      });

After resolving the issue, the updated code looked like this:

      $.ajax({
        url: link,
        dataType: 'json',
        type: 'get',
        success: function(html) {
          return _this.ajaxLoadIn(html);
        },
        error: function(e) {
          return alert('Sorry, something went wrong, please try again');
        }
      });

The mistake I made was setting the "type" parameter incorrectly. It should have been either GET or POST. Hopefully, this explanation provides some clarity on the situation.

Answer №2

If your backend doesn't accept URLs without trailing slashes (assuming you use them), it may attempt to redirect you to the correct URL with a trailing slash, causing the popup error. Be sure to use URLs with trailing slashes to avoid this issue.

When working with AngularJS RESTful infrastructure, keep in mind that $resource normally removes trailing slashes, but you can enable them starting from AngularJS 1.3.0. For more information, refer to the documentation.

Answer №3

Although this question is a decade old, it still pops up when searching for 'This page is being redirected to a new location'. I encountered the same issue when I changed the

network.http.prompt-temp-redirect
settings flag to true in Firefox's about:config. Reverting this setting back to false resolved the pop-up problem.

Some users have found success by adjusting other values as well; it might be worth checking them all:

  1. Open about:config in the Firefox URL bar
  2. Look for
    network.http.prompt-temp-redirect
    and make sure the value is set to false
  3. Check network.http.redirection-limit and ensure it is set to 20
  4. Search for
    browser.meta_refresh_when_inactive.disabled
    , and make sure it is false

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

Tips on saving a cookie using universal-cookie

I followed a solution on Stack Overflow to set a cookie in my React application. However, the cookie expires with the session. Is there a way I can make this cookie persist beyond the session so it remains even when the browser is closed and reopened? ex ...

Tips for concealing a dynamic DOM element using JQuery after it has been generated

My current project involves creating a form that allows users to dynamically add text fields by clicking on an "add option" button. Additionally, they should be able to remove added fields with a "remove option" link that is generated by JQuery along with ...

Converting strings into time formats in MongoDB

My string appears as follows: schedule_time = { start_time : "13:00", end_time : "14:10" } Now I need to convert it into time in MongoDB. I attempted using dateFromString but encountered some issues. The aggregation query: db.getCollection('appoi ...

Execute the component function located within one page using another page

Can someone help me understand how to trigger OnSwipe from inside a different JS file named CardFooter.js? This file contains a button with an OnClick event that triggers OnSwipe from the preceding JS file called CardItem.js. Both of these files are includ ...

Tips for configuring CakePHP to trigger the second submit button when the enter key is pressed

My form includes two submit buttons: "cancel" and "find." While both buttons work correctly when clicked, pressing the enter key always triggers the submission of "cancel." I don't want to change the button order in the form. To address this issue, I ...

Tips for customizing the appearance of popup windows

I want to enhance the appearance of my popup window by applying a different format for opening it. How can I style it so that it looks visually appealing when the popup window opens? You can find below the source code I am working with: HTML: <div onM ...

A hiccup in the Ajax request's journey

I apologize for the lengthy question... I need to insert a database record into a master table called test. Once the record is added, I need to retrieve the last inserted id and then insert approximately 1000 entries into a transaction table named test_tr ...

Understanding how to access and process data submitted to classic ASP through jQuery AJAX

Below is the Javascript code that I have written: function sendCcbRequest(text) { var jsonToSend = "\"text\": \"" + escape(text) + "\""; $.ajax({ type: "POST", url: 'x.asp', data: jsonToSend, ...

Is there a way for me to view the properties within the subcomponents?

Working on a project to create a bulletin board using React, following the official documentation. Decided to consolidate all actions related to the bulletin board into one alert component called AlertC. In the Form onSubmit statement, if the title is tr ...

Using Ajax to retrieve a Partial View in MVC 5

I've been trying to figure out how this is working, or not as the case may be. There's an Ajax call to my HomeController: function addPerson() { $.ajax({ dataType: "html", url: '@Url.Action("AddPerson")', ...

What steps are involved in utilizing a custom filter within ng-pluralize based on the count parameter?

<ng-pluralize count="data.amount | customFilter" when="{1: 'one item', 'other': '{} items'}"> </ng-pluralize> Is it possible to apply a custom filter to the count property? The customFilter function should return ...

I am having difficulty in crafting a sign-up form accurately

In my HTML file, I have a box that includes a sign-up form: <!-- sign up form --> <div id="cd-signup"> <form class="cd-form" action = "signup.php" > <?php echo "$error" ?> <p clas ...

Differences in behavior across operating systems when pasting content copied from Excel into Next.js

Exploring the Issue I am currently working on a project using Next.js 14 where users can paste data copied from an Excel file into a spreadsheet-like component called react-data-grid. However, I have encountered some inconsistencies when copy-pasting on M ...

Identify the moment all Dropzones are added to a form

I am working on a page where multiple dropzones are set up for individual images. Once the user submits the form, all the images attached to the dropzones are resized and then added to the rest of the form fields. After resizing and appending the images, ...

What is the easiest method to design an email subscription form that remains fixed on the top right corner of the screen?

Looking for advice on setting up a sleek email signup bar that remains at the top of the browser while users scroll and navigate through different pages. I am working with WordPress and have jquery already loaded, but have not yet worked with either. Up ...

Struggling with Creating Custom Validation Methods in JQuery

I'm currently implementing the JQuery validation plugin and have created a new method to check the availability of a name in the database. The PHP script is functioning properly, returning either 1 or 0 depending on availability. However, the method c ...

Managing bulk uploaded files using PHP

Currently, I am utilizing angular ng-upload for file uploads and here is my JavaScript code snippet: $scope.uploadFile = function(file) { Upload.upload({ url: '/upload_image', resumeChunkSize: '1MB', data: { ...

Building a table using a JSON object in a React component

I have been dynamically creating a table in React based on the API response received. data = {"name":"tom", "age":23, "group":null, "phone":xxx} Everything was working fine until I encountered a scenario w ...

The 'canvas' module could not be located in the system.Here are the required stacks:- /var/task/index.js- /var/runtime/index.mjs

I am currently developing a lambda function using the serverless framework. The function utilizes chartjs-node-canvas to create graphics, and everything runs smoothly on my MacBook when tested locally. However, when I deploy the function to AWS either dire ...

What is the jQuery method for generating a new element?

Is this the correct way to create an element: $('<div />') or $('<div></div>') Can you confirm if this is the proper syntax for creating an element? Thank you. ...