在React Native中使用XML-RPC

时间:2016-08-01 17:19:31

标签: javascript react-native xml-rpc

我尝试使用mimic javascript库在React Native中使用XML-RPC

这是我的代码:

import React, { Component } from 'react';
import {
  AppRegistry,
  View,
  Text
} from 'react-native';

const xmlrpc = require('./mimic');

class TestXmlRpc extends Component {
    constructor (props) {
        super(props);
        var request = new xmlrpc.XmlRpcRequest("http://192.168.43.10:8000", 'add');  
        request.addParam(1);  
        request.addParam(3);  
        var response = request.send();  
        console.log(response.parseXML()); 
    }
}

AppRegistry.registerComponent('TestXmlRpc', () => TestXmlRpc);

但我一直收到错误'不支持同步http请求' 我究竟做错了什么?很多

1 个答案:

答案 0 :(得分:0)

您必须更改此类呼叫

xhr.open("POST", this.serviceUrl, false);

进入

xhr.open("POST", this.serviceUrl, true);

因为现在需要异步