0

I have a jQuery code

        $.getJSON(
        "http://my.website.com/cors",
        {
                url: "https://www.someREST.com:8888/rest/v1",
                last: self.last(),
                first: self.first(),
                address: self.address()
        },
            function (data) {
                console.log(JSON.stringify(data.entry));
       });

but when I call that getJSON an URL parameter has added backslashes to each slash and encodeURIComponent() it makes even worse.

Any tips on that?

JackTheKnife
  • 3,795
  • 8
  • 57
  • 117

1 Answers1

0

Judging by what you have going on there, i think you are specifying too many URLS, http://api.jquery.com/jQuery.getJSON/

Try reformating like so

$.getJSON("https://www.someREST.com:8888/rest/v1",
    {
        last: self.last(),
        first: self.first(),
        address: self.address()
    },
        function (data) {
        console.log(JSON.stringify(data.entry));
   });

I'm not a CORS guy so I don't fully understand where you were going originally.

Mark Carpenter Jr
  • 812
  • 1
  • 16
  • 32
  • It must to go over `http://my.website.com/cors`as proxy for IE9 - other way is not going to work due to CORS – JackTheKnife Jun 23 '17 at 19:31
  • https://stackoverflow.com/questions/6396623/jquery-getjson-access-control-allow-origin-issue – Mark Carpenter Jr Jun 23 '17 at 20:26
  • There are other factors which doesn't allow to use direct `getJSON` from IE9 like request must be targeted to the same scheme as the hosting page (in this case HTTP vs HTTPS) that is why it must to be called via "proxy" app. – JackTheKnife Jun 23 '17 at 20:48