Chrome扩展程序Ajax请求

7
我是一名新手,正在开发一个谷歌浏览器扩展程序,需要向服务器发出jquery ajax请求,并加载一些html文档。我的服务器是Apache,在本地主机上使用XAMPP 1.7.3运行,而使用的jquery版本是jquery-1.6.1.js。
当我在标准浏览器(如Chrome)中加载它,比如http://localhost/Chrome/popup.html,jquery ajax可以正常工作。它也可以正常地加载html文档。但是,问题是当我在Google Chrome(Google Chrome 11)扩展程序开发模式下通过“加载未打包的扩展程序”打开我的扩展程序时,html文档无法加载。
有人能帮助我解决这个问题吗?
这是我的代码:

manifest.json

        {
        "name": "Nyu Extension",
        "version": "1.0",
        "description": "My First Extension",
        "permissions" : ["http://localhost/", "http://*/*"],
        "browser_action": {
        "default_icon": "N.png",
        "popup": "popup.html"
        }
        }

popup.html

        ...
        function activeTab(tab)
        {   
            document.getElementById("tab1").className = "";
            document.getElementById("tab"+tab).className = "active";           
            if(tab == 1)
            {
                $.ajax({
                    url: "ssc/contentpage1.txt",
                    success: function(data) {
                        $('#content').html(data);
                    }
                });
            }
        }
        ...

请告诉我是否有任何错误。
1个回答

8

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接