CIRCLE
CIRCLE

Reputation: 4879

Avoid URL encode

I've been developing an application where I do a lot of $.get to import the contents from other files into the project.

The name of the files have special characters like this =><.
For example: division_squaremeter_l=x<y.php.

Yesterday I had to publish a beta version for my client to see and since I've done that, all requests to those files have been URL encoded in my local machine.
I've manage to have it working on the server, but now, when I run the project on MAMP, I get a lot of 404 messages saying that those files doesn't exist.

And when I debug to see the name of the file, they appear like this: division_squaremeter_l=x%3Cy.php

I've tried avoiding URL encode using functions like decodeURIComponent() but with no success.

Is there a workaround for this problem?

This is a piece of my code:

$.get(BASE_URL+'sections/division_squaremeter_l=x<y.php', function(response){
    $('#DIVISION_CONTAINER_ONE').html(response);
});

Upvotes: 0

Views: 965

Answers (1)

hanshenrik
hanshenrik

Reputation: 21463

NEVER use encodeURI(). use encodeURIComponent() instead. the first 1 includes a lot of guessing from the browser, and is an unreliable relic from an ancient bad design decision.

Upvotes: 1

Related Questions