开发者

how to call aspx page from offline html with using jquery ajax

I have html page which is locate开发者_JAVA百科d on hard disk (in the browser: file:///C:/index.html). I want to load some data from aspx page when I open this html page. Aspx page is deployed on the webserver (e.g. http://servername/json.aspx) and returns json data:

Response.ContentType = "application/json";
Response.Write(jsonString);

I have tried a lot of combinations of jquery calls but not sucesfully.

Basically I want to achieve something like this:

<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>

Can somebody help me how to achieve this? thanks.


I think you're going to run afoul of the cross-domain policy with this. There are some potential hacks: http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/ if you must go down that path, but it's better (imo) to use a proxy of some kind or find another solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜