current position:Home>I don't know what to do when I encounter a problem

I don't know what to do when I encounter a problem

2022-02-03 20:58:43 Q & A of Denglian community


I met with such a problem

Then here's the code

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie=edge">    <title>Document</title>    <link rel="stylesheet" type="text/css" href="main.css">    <script src="![](file:///C:\Users\PC\AppData\Roaming\Tencent\QQTempSys\%[email protected]$ACOF(TYDYECOKVDYB.png)[email protected]/dist/web3.min.js"></script></head><body>    <div class="container">        <h1>Info Contract</h1>        <h2 id="info"></h2>        <label for="name" class="col-lg-2 control-label">Name</label>        <input id="name" type="text">        <label for="name" class="col-lg-2 control-label">Age</label>        <input id="age" type="text">        <button id="button">Update Info</button>    </div>    <script src="![](file:///C:\Users\PC\AppData\Roaming\Tencent\QQTempSys\%[email protected]$ACOF(TYDYECOKVDYB.png)"></script>    <script>    var web3 = new Web3('');    web3.setProvider('');    var infoContract = new web3.eth.Contract([    {        "constant": true,        "inputs": [],        "name": "getInfo",        "outputs": [            {                "internalType": "string",                "name": "",                "type": "string"            },            {                "internalType": "uint256",                "name": "",                "type": "uint256"            }        ],        "payable": false,        "stateMutability": "view",        "type": "function"    },    {        "constant": false,        "inputs": [            {                "internalType": "string",                "name": "_fname",                "type": "string"            },            {                "internalType": "uint256",                "name": "_age",                "type": "uint256"            }        ],        "name": "setInfo",        "outputs": [],        "payable": false,        "stateMutability": "nonpayable",        "type": "function"    }],'0xf983cfb115baff13df2beff7c9c6b825c6fc20c7')console.log("abc"+web3);  infoContract.methods.getInfo().call({from: '0xf983cfb115baff13df2beff7c9c6b825c6fc20c7'}, function(error, result){  if(!error)      {        $("#info").html(result[0]+' ('+result[1]+' years old)');        console.log(result);      }  else      console.error(error);    });  </script></body></html>

Other answers 1:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.

Random recommended