Internet Explorer 11 and the process of URL encoding

Hello there! I am currently working on an MVC project with Angular where I am utilizing a JsonResult to return JSON data from a list containing emails with a specific date.

Below is the AJAX call I'm making from Angular:

myApp.service('mailService', function ($http) {
    this.getEmailByDate = function (date) {
        return $http.get("/Home/ShowEmailByDate/", { params: { date: date } });
    };
}); 

This is my JsonResult in the Controller:

public JsonResult ShowEmailByDate(string date)
{
    var selectedMsg = ClassHelper.listMsg;

    var result = selectedMsg.Select(s => new
    {
        From = s.From.RawValue,
        Date = s.Date.ToString("F"),
        searchDate = s.Date.ToString("dd/MM/yyyy"),
        sortDate = s.Date.ToString("M"),
        sortTime = s.Date.ToString("t"),
        Subject = s.Subject,
        Body = s.BodyHtml,
        Attachments = s.AttachmentFiles.Count(),
        Files = s.AttachmentFiles.Select(f => f.FileName)
    })
    .Where(s => s.searchDate == date)
    .OrderByDescending(s => s.sortDate)
    .ThenByDescending(s => s.sortTime);

    return Json(result, JsonRequestBehavior.AllowGet);
}   

Now, the issue I'm facing seems to occur only in Internet Explorer. It works perfectly fine on Chrome and Firefox. The URL that I observe in developer mode under the Network tab when I trigger the AJAX call appears like this:

htttp://localhost:0000/Home/ShowEmailByDate/?date=%E2%80%8E23%E2%80%8E%2F%E2%80%8E12%E2%80%8E%2F%E2%80%8E2015     

As a result, I receive an empty array response []

On the other hand, in Firefox and Chrome, the URL looks like this:

htttp://localhost:0000/Home/ShowEmailByDate/?date=22%2F12%2F2015 and it works as expected.

The 'date' parameter is formatted as a string such as 22/12/2015 'dd/M/yyyy'

Any suggestions? Thank you!

Answer №1

To ensure consistent output URLs in Internet Explorer, Chrome, and Firefox, you must decode the URL before using it.

Utilize the decodeURI() function to properly decode a URI.

var uri = "%E2%80%8E23%E2%80%8E%2F%E2%80%8E12%E2%80%8E%2F%E2%80%8E2015";
var dec = decodeURI(uri);
var res = "Decoded URI: " + dec;
document.getElementById("demo").innerHTML = res;
<p id="demo"></p>

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

sending multiple checkbox selections to a PHP script using jQuery

<form id="foo"> <input type="text" name="voucher" placeholder="voucher ID" class="bill_fillter"/> <input type="text" name="voucher" placeholder="voucher ID" class="bill_fillter"/> <input type="text" name="voucher" placeholder="voucher ...

Anticipating the refresh of React state in a functional component

I am looking for a way to ensure that the function handleOpen is only called after all the state variables (nameError, emailError, messageError) have been updated. The issue I am facing is that the state update is not instantaneous, causing handleOpen to s ...

Challenge with the submission event listener

I am struggling to create my first event listener for the submit button that should respond to both a click and an enter key press. Currently, it is not working for either event, and I am unsure why. I do not intend to send any data to another page; I simp ...

What is the best way to execute multiple spec files in Cypress version 10?

I have recently upgraded to cypress 10.0.0 and I am trying to integrate multiple test (spec) files in cypress.config.ts. Is it possible with the latest cypress update? import { defineConfig } from "cypress"; export default defineConfig({ e2e ...

Having difficulty accessing a public array item within chained AXIO transactions in VUE

I am currently facing an issue with a chained AXIOS call that is triggered from an array. The challenge I am encountering is ensuring that the second call completes before the first one initiates another API request, which seems to be working fine so far. ...

What is the best way to generate a random string output from an object in JavaScript?

I'm struggling with extracting a random value from the object provided below, can anyone help me out? const hellos = { English: "Hello", Japanese: "Konnichiwa", German: "Hallo", Spanish: "Hola", Arabic: "Ah ...

Using regex to confirm prices are accurate

Can anyone assist me with validating input using regEx in Vue? I'm struggling to create one and haven't been able to find the correct pattern online for what I need. The specific validation I am attempting is for a price value that should be a f ...

Handling AJAX calls in ASP.NET platform

Currently, I am using AJAX button and label controls. The idea is that when the user clicks the button, the data in the label gets updated instantly. The issue I am facing is that after clicking the button, the Page_Load event triggers, resetting all the ...

Using a conditional statement in JavaScript, create a mapping between the values in an array and string

I have a dropdown list that I want to populate with options. The functionality of the onchange event is handled by the following code snippet: const handleChange = (event) => { onFilterChange(filterName, event.target.value); } The value of event.ta ...

Dynamically changing the borders of WebGL canvases: a guide to adding and

Here is my code snippet for creating an HTML canvas: <canvas id="glCanvas" class="canvases" width="20" height="20></canvas> To set the color, I am using the following: gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clear(gl.COLOR_BUFFER_BIT); I am w ...

What could be causing me to consistently receive a 0 value despite my collection having content stored within it?

How can I retrieve the value of dropVolume and use it in another method after executing my getAllDropsVolumePerDate(date) function? Each time I try to access dropVolume, it returns a value of 0. dropVolume = 0; getAllDropsVolumePerDate(date: string) { ...

passport-local-mongoose req.user is currently not defined

While implementing passport js with the passport local mongoose plugin, I am facing a specific issue. Account creation and logging in are functioning properly. However, once logged in, passport fails to recognize me as a logged-in user. The code snippets ...

Error: Controller fails to load after using jQuery's append method

Currently, I am utilizing jQuery to showcase modal windows. The process involves generating HTML using a function and then executing $('#myElement').append(modalHtml); Within the modal HTML, there is <div ng-controller="MyController">...&l ...

Accessing Flipkart API using CORS: A step-by-step guide

Trying to retrieve data from the following URL using a jQuery ajax call: Ajax request $.ajax({ type:"GET", url: 'https://affiliate-api.flipkart.net/affiliate/report/orders/detail/xml?startDate=2015-05-01&amp;endDate=2015-05-30&amp;st ...

Tips for creating multiple popups using a single line of JavaScript code

I am new to JavaScript and I am attempting to create a popup. However, I am facing an issue in opening two divs with a single line of JavaScript code. Only one div opens while the other remains closed despite trying various solutions found on this website. ...

Navigating through options in angularjs with a dropdown for effective searching

I need help with implementing a dropdown search filter for my folder and category lists. Here is the code I currently have: <!--folder start--> <div class="form-group"> <div class="col-sm-2"> <select class="form-control" ...

ways to disrupt a timeout

I am attempting to incorporate a functionality similar to this example: https://www.w3schools.com/jsref/met_win_cleartimeout.asp On my personal website: If you enter certain characters in the input field, select one of them, and then pause for 5 seconds, ...

Interacting with objects in a loaded OBJ model using ThreeJS

I have an obj model representing a map with tree objects. After successfully loading the model, I am trying to access one specific tree object named Tree1. How can I achieve this? Currently, my code looks like this: loader.load( 'map.obj', fun ...

Error message: Unable to access .exe file through HTML link

We have a need to include an HTML link on our intranet site that, when clicked, will open an .exe file that is already installed on all user machines. I attempted the following code: <a href = "C:\Program Files\Cisco Systems\VPN&bsol ...

AngularJS and Handlebars (npm)

Is it possible for angularJS to function as a substitute for the "view engine" in nodeJS? I am seeking insights on the optimal method to use. (Do MEAN Stack developers utilize view engines? Or do they prefer using res.sendFile along with tools like ui-ro ...