Domanda

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',
      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.

È stato utile?

Soluzione

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!!!');
  }
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top