gpt4 book ai didi

javascript - $.get 不工作

转载 作者:行者123 更新时间:2023-11-30 13:38:55 26 4
gpt4 key购买 nike

我用这个方法加载页面...

function remoteCall(sUrl, sQueryStr, sCalledBy)
{
var str = " { ";

$.post(sUrl,sQueryStr, function(data){
sResponse[sCalledBy] = data; //alert(data);
eval(" "+sCalledBy+"()");
});
}

但是当我将 $.post 更改为 $.get 时,它不起作用。实际上我需要更改它,因为我正在从远程页面加载此页面。

最佳答案

i need to change this bcoz i am loading this page from remote page....

你需要看看Same Origin Policy :

In computing, the same origin policy is an important security concept for a number of browser-side programming languages, such as JavaScript. The policy permits scripts running on pages originating from the same site to access each other's methods and properties with no specific restrictions, but prevents access to most methods and properties across pages on different sites.

为了能够获取数据,它必须是:

相同的协议(protocol)和主机

您需要实现 JSONP解决它。

关于javascript - $.get 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3378019/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com