How can I allow people access to my datafeed with javascript

Discussion in 'Javascript' started by matt@smartlegacy.com, Jun 16, 2006.

  1. Guest

    I get this error: Error: uncaught exception: Permission denied to call
    method XMLHttpRequest.open

    I think I need to sign my script, but not sure if what I want to do
    will even work.

    So let me explain.

    I have a datafeed on my site www.mysite.com
    for simplicity it is a php page with only <?PHP echo "Hello"; ?>

    I have a .js file on www.mysite.com that reads the php file.
    CODE:
    -----------------------------------------------------------------
    var xmlHttp
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
    xmlHttp=new XMLHttpRequest();
    xmlHttp.onreadystatechange = stateChanged;
    xmlHttp.open("Get", "http://www.mysite.com/Get_News.php")
    xmlHttp.send(null)

    function stateChanged()
    {

    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    document.getElementById("output").innerHTML=xmlHttp.responseText
    }
    }

    function GetXmlHttpObject(handler)
    {
    var objXmlHttp=null

    if (navigator.userAgent.indexOf("Opera")>=0)
    {
    alert("This example doesn't work in Opera")
    return
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
    var strName="Msxml2.XMLHTTP"
    if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
    {
    strName="Microsoft.XMLHTTP"
    }
    try
    {
    objXmlHttp=new ActiveXObject(strName)
    objXmlHttp.onreadystatechange=handler
    return objXmlHttp
    }
    catch(e)
    {
    alert("Error. Scripting for ActiveX might be disabled")
    return
    }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
    objXmlHttp=new XMLHttpRequest()
    objXmlHttp.onload=handler
    objXmlHttp.onerror=handler
    return objXmlHttp
    }
    }
    --------------------------------------------------------------------------
    I want other people to be able to just add a <script> to their site
    that accesses my .js file and output the data to their site.

    here is the sample of of the script:
    <script src="http://www.mysite.com/ajax_notify.js"
    type="text/javascript"></script>
    <div id="output"></DIV>

    Is this possible? To allow the public to access a js file on my server
    to read my data and display on their site?

    If I do need to sign the javescript, how do I do that?
    , Jun 16, 2006
    #1
    1. Advertising

  2. Guest

    An example of what I want to do is similar to google adwords:

    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    , Jun 16, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Peterson

    Datafeed to Excell

    Steve Peterson, Feb 1, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    358
    sloan
    Feb 1, 2006
  2. Jeff
    Replies:
    2
    Views:
    927
    clintonG
    Sep 19, 2006
  3. Replies:
    1
    Views:
    693
    Roger Lindsjö
    Jun 11, 2008
  4. c676228
    Replies:
    3
    Views:
    128
    Luke Zhang [MSFT]
    Nov 21, 2006
  5. Sam
    Replies:
    4
    Views:
    63
    Mark Lawrence
    Jan 17, 2014
Loading...

Share This Page