Ad Widget

Collapse

help javascript api

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • checifaccioqua?
    Junior Member
    • Mar 2011
    • 14

    #1

    help javascript api

    HI,
    first sorry for my bad inglish........!!!

    This is my problem....I'm not able to connect zabbix api. I followed this code(previosly posted on this forum=>http://www.zabbix.com/forum/showthre...t=14048&page=2)

    Code:
    <HTML>
    <script type="text/javascript">
    
    var the_object;
    var http_request = new XMLHttpRequest();
    var jsonrpc = {'jsonrpc': '2.0','method': 'user.authenticate','params': {'user': 'nome', 'password': 'nome'},'id': 1};
    http_request.open( "POST", '<zabbix_server_path>/zabbix/api_jsonrpc.php', true );
    http_request.setRequestHeader('Content-Type', 'application/json-rpc');
    http_request.send(jsonrpc);
    http_request.onreadystatechange = function () {
        if ( http_request.readyState == 4 ) {
            if ( http_request.status == 200 ) {
                the_object = eval( "(" + http_request.responseText + ")" );
                    document.getElementById("zone").innerHTML = http_request.responseText;
            } else {
                alert( "There was a problem with the URL." );
            }
            http_request = null;
        }
    };
    
    </script>
    <div id="zone"></div>
    </HTML>
    I create a zabbix user with api access but don't work!!!! Please help me!!!!!!!!!!!!!!!!!!!
  • Kodai
    Junior Member
    • Mar 2006
    • 8

    #2
    Where do you put your html file?

    Browser has "Same origin policy", so you have to put html and javascript file on the same server that Zabbix web interface is running.
    Kodai Terashima
    [URL="http://www.zabbix.jp"]ZABBIX-JP[/URL] - Japanese Zabbix community

    Comment

    Working...