Form data posting and Receiving response

I' am a newbie in Rust programming. I'am learning webassembly. I have created a form which accepts two string and I want them concatenated and show the concatenated result in the html page. For academic interest I want my concatenation logic to reside in Rust. Can I get some help on how to do Form POST with Javascript to Rust library and receive a response back.

<!DOCTYPE html>
          body {
              position: absolute;
              top: 0;
              left: 0;
              width: 100%;
              height: 100%;
              display: flex;
              flex-direction: column;
              align-items: center;
              justify-content: center;
            #fps {
              white-space: pre;
              font-family: monospace;
    <meta charset="utf-8">
    <title>Hello wasm-pack!</title>
      <form >
          <div id="fps">
        First String<input type="text" id="a1"><br>
        Second String<input type="text" id="a2"><br>
        <button type="button" id="bt" >Concatenate</button><br>
        Result<input type="type" id="re">
   <script type="text/javascript" src=""></script>
    <script src="./bootstrap.js"></script>

import * as wasm from "wasm-game-of-life";

    var a=document.getElementById("a1").value;
    var b=document.getElementById("a2").value;
    const result=wasm.concat(a,b);

Rust code

mod utils;
 extern crate web_sys;
use wasm_bindgen::prelude::*;
 use web_sys::console;
#[cfg(feature = "wee_alloc")]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

pub fn concat(s1 :&str,s2 :&str)->String
    let  str1=s1.to_string();
    let  str2=s2.to_string();
    let concate=str1+&str2;

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.