FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
2,894 views 4 comments
by anonymous
I try to make a html page where I want to show some detail of my RUT955 (GPS coordinates, I/O ...).

I want to do this with the JSON RPC procedure. Like explain in the wiki page I try first this with the add-on of firefox and everything works nice.

Now i'm trying to implement this in a html page (php, javascript or ...) but this doesn't work. Can anyone help me? I show a part of my javascript, maybe I make a small mistake !?

Thanks in advance !

Code:

<html>

<head>

   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>

   <script>

      $(document).ready(function(){

         $.ajax({

            url: 'http://192.168.1.1/ubus',

            data: JSON.stringify ({"jsonrpc":"2.0", "id":1, "method":"call", "params":["00000000000000000000000000000000", "session", "login",{"username":"root", "password":"password"}]} ),

            type:"POST",

            dataType:"json",

            success:  function (data)       

            { alert("The result is : " + data.result);},

            error: function (err)  { alert ("Error");}

         });

      });

 </script>

</head>

<body>

  <h1> JSON RPC 2.0 demo </h1>

</body>

</html>
by anonymous
Can someone give me more explanation.....
by

Hi Jeroeng

I have been trying exactly the same with an Ajax call. Did you have success?  Would love to hear your HTTP AJAX POST solution. !

BTW, I am also trying to do this from C# controller but is only halfway. Got the "session-Id" successfully, but now needs to POST the session ID plus command.. Not successful with C# (yet) as I am getting a return {"jsonrpc":"2.0","id":1,"result":[0,{"code":0}]}.... because of unable to send ["-x"].

Any suggestions in the forum ?

Many thanks

HelmiDreijer@gmail.com

1 Answer

0 votes
by
I would redesign how you want to do this, you are giving out your API credentials in the header of the html file. Anything that can be hacked this easy will be hacked.
by anonymous
understood, can you give me an example?