0

In my jQuery script I have an Ajax call to an url like : http://tokenvalue@example.com.

When I made a request with $.ajax or $.get, jquery remove the tokenvalue. So authentication failed.

$.ajax({
    type: 'GET',
    url: "http://tokenvalue@example.com"
},

Why does jQuery remove it ? And how to fix that ?

Thanks.

recnac
  • 3,744
  • 6
  • 24
  • 46
jeremieca
  • 1,156
  • 2
  • 13
  • 38
  • Try using `encodeURIComponent`. https://www.w3schools.com/jsref/jsref_encodeURIComponent.asp – Furquan Khan Jun 05 '18 at 12:06
  • Thansk for your help but it doesn't work. My question is not about encoding the URI. It's about keeping the username in the url. – jeremieca Jun 05 '18 at 12:11
  • `http://tokenvalue@example.com` is not a valid URL – Nitin Sawant Jun 05 '18 at 13:08
  • It's an url with an username and no password. Maybe it's not valid but Dataiku Api give url like that. But I finally fix my problem using ```xhrFields.withCredentials```. – jeremieca Jun 05 '18 at 14:08

0 Answers0