简体   繁体   English

jQuery.getJSON和URL作为参数

[英]jQuery.getJSON and an URL as parameter

I have a jQuery code 我有一个jQuery代码

        $.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. 但是当我调用getJSON ,URL参数已将反斜杠添加到每个斜杠和encodeURIComponent()这使情况更糟。

Any tips on that? 有什么提示吗?

Judging by what you have going on there, i think you are specifying too many URLS, http://api.jquery.com/jQuery.getJSON/ 从您的情况来看,我认为您指定的URL太多, 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. 我不是CORS的人,所以我不完全了解您的原路。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM