xbmc jsonrpc и jquery - PullRequest
       40

xbmc jsonrpc и jquery

1 голос
/ 15 мая 2011

В основном я пытаюсь опросить мой xbmc, используя jsonrpc со следующим:

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

$.ajax({
      dataType: 'jsonp',
      data: _data,
      jsonp: 'jsonp_callback',
      url: _XBMCHOST,
      success: function () {
          console.log( 'here here here');
      },

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

Но я продолжаю возвращаться parsererror . Однако я могу успешно запустить тот же пост через curl и получить желаемый результат, например:

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

Буду признателен за любые предложения или помощь.

1 Ответ

2 голосов
/ 16 мая 2011

Используемая вами команда curl - POST, а команда jquery - GET. Попробуйте вместо этого:

$.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!!!');
  }
});
...