问题描述
||
我有位于硬盘上的html页面(在浏览器中:file:/// C:/index.html)。当我打开此html页面时,我想从aspx页面加载一些数据。
Aspx页面已部署在Web服务器上(例如http://servername/json.aspx)并返回json数据:
Response.ContentType = \"application/json\";
Response.Write(jsonString);
我尝试了很多jquery调用的组合,但未成功。
基本上我想实现以下目标:
<script type=\"text/javascript\">
$().ready(function()
{
$(\"#myButt\").click(function()
{
$.ajax({
type: \"GET\",url: \"http://servername/json.aspx\",data: \"id=1\",success: function(msg){
alert(msg);
},});
});
});
</script>
有人可以帮我实现这个目标吗?
谢谢。
解决方法
我认为您将因此违反跨域政策。有一些潜在的骇客:http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/如果您必须沿着这条路走,那么最好使用(imo)使用代理某种或找到另一种解决方案。