i have question using react function set in c# has controller values via url.
this controller:
[httpget("{number}/{source}/{aux}/{destination}")] public string get(int number, string source, string aux, string destination) { hanoi h = new hanoi(); return h.movedisks(number, source, aux, destination); }
this i've tried far:
<script type="text/babel"> var form = react.createclass({ calculate: function () { var xhttp = new xmlhttprequest(); xhttp.onreadystatechange = function() { if (xhttp.readystate == 4 && xhttp.status == 200) { document.getelementbyid("moves").innerhtml = xhttp.responsetext; } }; xhttp.open("get", "api/values" + "/" + "number" + "/" + "src" + "/" + "aux" + "/" + "dest", true); xhttp.send(); }, render: function (){ return ( <div> number of rings: <input type="number" id="number"/> <br /><br /> source: <input type="text" id="src"/><br /><br /> auxiliary: <input type="text" id="aux"/><br /><br /> destination: <input type="text" id="dest"/><br /><br /> <button onclick={this.calculate}>get result!</button> </div> ); } }); reactdom.render(<form />, document.getelementbyid('form')); </script> <div id="form"></div> <div id="moves"></div>
i want result posted in "moves" div, can't figure out how. trying use react in way it's not supposed work?
i'm beginner appreciated.
you need correct api route
[httpget] [route("api/values/{number}/{source}/{aux}/{destination}")] public string get(int number, string source, string aux, string destination) { hanoi h = new hanoi(); return h.movedisks(number, source, aux, destination); }
Comments
Post a Comment