开发者

xbmc jsonrpc and jquery

开发者 https://www.devze.com 2023-03-05 20:48 出处:网络
Basically I\'m trying to poll my xbmc using the jsonrpc with the following: _data = \'{\"jsonrpc\":\"2.0\", \"method\":\"VideoLibrary.GetMovies\", \"id\":\"1\"}\';

Basically I'm trying to poll my xbmc using the jsonrpc with the following:

_data = '{"jsonrpc":"2.0", "method":"VideoLibrary.GetMovies", "id":"1"}';
_XBMCHOST = "http://192.168.0.140:8080/jsonrpc";

$.ajax({
      dataType: 'jsonp',
    开发者_Python百科  data: _data,
      jsonp: 'jsonp_callback',
      url: _XBMCHOST,
      success: function () {
          console.log( 'here here here');
      },

      error:function( result ){
         console.log( result );
         console.log('error!!!');
      }
  });

But I keep getting back parsererror. I can however run the same post successfully through curl and get back the desired results, ie:

curl -i -X POST -d '{"jsonrpc":"2.0", "method":"VideoLibrary.GetMovies", "id":"1"}' http://192.168.0.140:8080/jsonrpc

Any suggestions or help would be appreciated.


The curl command you are using is a POST whereas the jquery command is a GET. Try this instead:

$.ajax({
  dataType: 'jsonp',
  data: _data,
  jsonp: 'jsonp_callback',
  url: _XBMCHOST,
  type: 'post', //make this a post instead of a get
  success: function () {
      console.log( 'here here here');
  },

  error:function( result ){
     console.log( result );
     console.log('error!!!');
  }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号