Search code examples
javascriptajaxfirefoxfirefox-addonfirefox-addon-sdk

Ajax in Firefox add on panel content JavaScript


i use Firefox Add on SDK . i have button in toolbar and in On Click Event I Show the panel html file . now i need to use ajax function in On click of html button i used in panel html file.


    <html>
    <script>
    function test()
    {
    var xhr=new XMLHttpRequest();
    //some ajax Code 
    }
    </script>
    <button onclick='test()'>click Here</button>
    </html>

i am new in using Firefox SDK. Is It possible at all ?? and if it is possible then how should i do this ?


Solution

  • You can't use inline scripting inside a html page in a Firefox addon, add the script as a packaged local resource and it will be executed.

    Basically you have to split in two, the HTML and the JS and reference the JS in the HTML