基本上,我试图使用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!!!');
}
});但我一直在找帕瑟错误。不过,我可以通过curl成功地运行同一篇文章,并返回所需的结果,即:
curl -i -X POST -d '{"jsonrpc":"2.0", "method":"VideoLibrary.GetMovies", "id":"1"}' http://192.168.0.140:8080/jsonrpc如有任何建议或帮助,将不胜感激。
发布于 2011-05-15 22:05:14
您使用的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!!!');
}
});https://stackoverflow.com/questions/6009745
复制相似问题