Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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, load 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..

like image 982
wahyueka31 Avatar asked May 15 '11 06:05

wahyueka31


People also ask

How do I get Ajax request?

send = function() { console. log( arguments ); //Here is where you can add any code to process the request. //If you want to pass the Ajax request object, pass the 'pointer' below var pointer = this var intervalId = window. setInterval(function(){ if(pointer. readyState !=

How do you send a Chrome extension request?

Type the url in the main input field and choose the method to use: GET/POST/PUT/DELETE/PATCH. Click on the arrow "Send" or press Ctrl+Enter.


1 Answers

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

like image 176
Mihai Parparita Avatar answered Nov 13 '22 04:11

Mihai Parparita