Node.js and postgresql delete with ajax

366
December 03, 2017, at 6:57 PM

postgre sql and nodejs I am trying to delete an operation. I delete it but it does not seem to refresh the page. How can I delete the page without having to refresh the page?

node js code is this

app.delete('/delete/:id',function(req,res){
pool.query('DELETE FROM recipes WHERE id = $1',
[req.params.id])
res.send(200);
})

my jquery code is this

$(document).ready(function(){
$('.delete-recipe').on('click',function(){
    var id = $(this).data('id');
    var url = '/delete/'+id;
    if(confirm('Delete Recipe?')){
        $.ajax({
            url : url,
            type: 'DELETE',
            succes : function(result){
                console.log('delegitng');
                window.location.href='/';
            },
            error : function(err){
                console.log(err);
            }
        });
    }
})
})
Rent Charter Buses Company
READ ALSO
Virtual host (vhost) on heroku and express empty host

Virtual host (vhost) on heroku and express empty host

im using the vhost package for expressjs and im having a pretty important problem, at least for mePart of the architecture i had thought was to use a virtual host, have many different sites in the same heroku instance and share the same server

202
using backend files nodejs

using backend files nodejs

Sorry, It might be very novice problem but I am new to node and web apps and just have been stuck on this for couples of days

266
Geocoding for current location

Geocoding for current location

enter image description hereSo I'm trying to reverse geocode current location of users from longitude,latitude in google map

332
Use index.js to import multiple image assets in React

Use index.js to import multiple image assets in React

I have been using a pattern of collecting component files for export with indexjs files placed in directories, for example:

685