javascript - how to make get route after a post route completes in nodejs? -


this html form . need submit name , url.

<form action="/myaction" method="post" id="addform">     <label>name</label>     <input type="text" class="form-control" id="inputname" name="inputname" placeholder="hostname" />         <label>url</label>     <input type="text" class="form-control" id="inputurl" name="inputurl" placeholder="url" />         <button type="submit" class="btn btn-success" onclick="form_submit();"><i class="glyphicon glyphicon-ok"></i> save</button>  </form> 

this form_submit function. need submit name , url.

function form_submit() {     document.getelementbyid("addform").submit();     $('#addform').submit(function() {         $.ajax({             url: $('#addform').attr('action'),             type: 'post',             data: $('#addform').serialize(),             success: function(data) {                 console.log('form submitted.' + data);              }         });         $('#servicetable').bootstraptable({});         return false;      });  } 

this nodejs post call update db

app.post('/myaction', function(req, res) {      var newhostname = req.body.inputname;     var newurl = req.body.inputurl;     db.insert({         _id: newhostname,         url: "https://" + newurl + "/dispatcher/v1/monitoring/status"     }, function(err, body) {         if (!err)             console.log("error in myaction" + body)     }) }); 

i need update table dynamically when user enters name , url.

but example if user enters

name :"xxx" url :"https://myurl/myvalues"

i need make call using user submitted url. 1)first need post name , url value db. 2)then need latest url , name , make ajax call values url. 3)then have update boostrap-table dynamically.

i'm able post data i'm not able data db , make ajax call simultaneously .

if has idea please suggest me. lot!

if wrong please tell me before giving negative votes. i'm new nodejs.thank you


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -