开发者

Chrome Extension Ajax Request

I am a newbie and working on a google-chrome extension, that needs to make jquery ajax requests to a server, loa开发者_Go百科d some html documents . My server is Apache, running on localhost using XAMPP 1.7.3. an the jquery is jquery-1.6.1.js.

When I load it using standard browser like chrome like http://localhost/Chrome/popup.html, the jquery ajax works. And it loads the html documents funtionaly. But, the problem is when I open my extension by "Load unpacked extension" in Google Chrome (Google Chrome 11) extension developer mode. The html document won't load.

Anyone can help solving my ploblem?

this is my code :

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);
                    }
                });
            }
        }
        ...

please tell me if anything wrong..


You should specify an absolute (full) URL in the $.ajax call (i.e. http://localhost/Chrome/ssc/contentpage1.txt).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜