1

基本的に、次のようにjsonrpcを使用してxbmcをポーリングしようとしています:

_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

提案や助けをいただければ幸いです。

4

1 に答える 1

2

使用しているcurlコマンドはaですが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!!!');
  }
});
于 2011-05-15T22:05:14.913 に答える