【问题标题】:Consuming XML-RPC in React Native在 React Native 中使用 XML-RPC
【发布时间】:2016-12-06 20:58:29
【问题描述】:

我正在尝试使用 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 请求” 我究竟做错了什么?非常感谢

【问题讨论】:

  • 有人有这方面的吗?我也有同样的问题

标签: javascript react-native xml-rpc


【解决方案1】:

您必须更改此类调用

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

进入

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

因为现在需要异步

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-30
    • 1970-01-01
    • 1970-01-01
    • 2013-09-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多